Skip to content

Commit

Permalink
Merge pull request #1497 from tweag/bazel-update
Browse files Browse the repository at this point in the history
Update to Bazel 4.0.0
  • Loading branch information
mergify[bot] authored Feb 25, 2021
2 parents 4ee37f3 + 5688d62 commit cf1300c
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 18 deletions.
1 change: 0 additions & 1 deletion .ci/bazel-3.7.2-darwin-x86_64.sha256

This file was deleted.

1 change: 0 additions & 1 deletion .ci/bazel-3.7.2-linux-x86_64.sha256

This file was deleted.

1 change: 0 additions & 1 deletion .ci/bazel-3.7.2-windows-x86_64.exe.sha256

This file was deleted.

1 change: 1 addition & 0 deletions .ci/bazel-4.0.0-darwin-x86_64.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
349f3c9dd24191369c1073c57cc1386fc3c2d4ad7d44135c3d873c9dc67fae1f bazel-4.0.0-darwin-x86_64
1 change: 1 addition & 0 deletions .ci/bazel-4.0.0-linux-x86_64.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7bee349a626281fc8b8d04a7a0b0358492712377400ab12533aeb39c2eb2b901 bazel-4.0.0-linux-x86_64
1 change: 1 addition & 0 deletions .ci/bazel-4.0.0-windows-x86_64.exe.sha256
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
43930bbbc8b5d618884ee8145e1ec181760bf9eea42d16217a30381d176e4cf6 bazel-4.0.0-windows-x86_64.exe
2 changes: 1 addition & 1 deletion .ci/bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.2
4.0.0
45 changes: 39 additions & 6 deletions haskell/private/cc_wrapper.py.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,26 @@ used to avoid command line length limitations.
See https://gitlab.haskell.org/ghc/ghc/issues/17185.
- Fixes invocations that handle temporary and intermediate binaries
- Fixes invocations that handle temporary and intermediate binaries.
GHC with Template Haskell or tools like hsc2hs build temporary Haskell
binaries (that e.g. generate other Haskell code) as part of the build
process. This wrapper ensures that linking behaviour for these binaries
matches the characteristics of the wider build (e.g. runpath configuration,
etc.)
- Avoids arguments starting with `@`.
Bazel 4.0.0 has its own cc_wrapper on macOS which attempts to expand any
argument starting with `@` as a response file. This will wrongly interpret
the follwoing types of arguments as referencing a response file:
-install_name @rpath/...
-Xlinker -rpath -Xlinker @executable_path/...
-Xlinker -rpath -Xlinker @loader_path/...
See https://github.com/bazelbuild/bazel/pull/13044
"""

from bazel_tools.tools.python.runfiles import runfiles as bazel_runfiles
Expand Down Expand Up @@ -198,6 +210,8 @@ class Args:
pass
elif self._handle_linker_arg(arg, args, out):
pass
elif self._handle_install_name(arg, args, out):
pass
elif self._handle_print_file_name(arg, args, out):
pass
elif self._handle_compile(arg, args, out):
Expand Down Expand Up @@ -324,7 +338,15 @@ class Args:
raise RuntimeError("Unhandled _prev_ld_arg '{}'.".format(self._prev_ld_arg))

if forward_ld_args:
if use_xlinker:
# Avoid arguments starting with `@`, see module docstring.
# Use `-Wl,...` in those cases instead of `-Xlinker ...`.
starts_with_at = any(
ld_arg.startswith("@rpath") or
ld_arg.startswith("@loader_path") or
ld_arg.startswith("@executable_path")
for ld_arg in forward_ld_args
)
if use_xlinker and not starts_with_at:
out.extend(
arg
for ld_arg in forward_ld_args
Expand All @@ -335,6 +357,18 @@ class Args:

return True

def _handle_install_name(self, arg, args, out):
consumed, install_name = argument(arg, args, long = "-install_name")

if consumed:
# Avoid arguments starting with `@`, see module docstring.
# The compiler wrapper forwards `-install_name` to the linker.
# Here we use `-Wl,-install_name,...` directly to send the flag to
# the linker and avoid an argument starting with `@`.
out.append("-Wl,-install_name,{}".format(install_name))

return consumed

def _handle_rpath(self, rpath, out):
# Filter out all RPATH flags for now and manually add the needed ones
# later on.
Expand Down Expand Up @@ -518,11 +552,10 @@ def shorten_path(input_path):

def rpath_args(rpaths):
"""Generate arguments for RUNPATHs."""
# Avoid arguments starting with `@`, see module docstring.
# Pass `-rpath` flags using `-Wl,...` instead of `-Xlinker ...`.
for rpath in rpaths:
yield "-Xlinker"
yield "-rpath"
yield "-Xlinker"
yield rpath
yield "-Wl,-rpath,{}".format(rpath)


# --------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion haskell/private/versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def check_version(actual_version):
# Please use length 3 tuples, because bazel versions has 3 members;
# to avoid surprising behaviors (for example (2,0) >/= (2, 0, 0))
min_bazel = (2, 1, 0) # Change THIS LINE when changing bazel min version
max_bazel = (3, 7, 2) # Change THIS LINE when changing bazel max version
max_bazel = (4, 0, 0) # Change THIS LINE when changing bazel max version

actual = tuple(_parse_bazel_version(actual_version))

Expand Down
6 changes: 3 additions & 3 deletions nixpkgs/default.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let
# 2021-02-04
sha256 = "1bkjh566r1bpbddz6fjhccn872p1dlvg5fwq9j2qdj4b5q2pmljc";
rev = "24e5fe6075bc7a137bb701eb8a378f5a8689e10d";
# 2021-02-19
sha256 = "1fwl898f6wznkjpwq11brgadz6iff5w5f4lwj2l7ax2rz7r03mnn";
rev = "ad4db3f4d8ae54482c63c31c14921cb73953548d";
in
import (fetchTarball {
inherit sha256;
Expand Down
4 changes: 2 additions & 2 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mkShell {
which
perl
python3
bazel
bazel_4
jdk11
# For stack_install.
stack
Expand Down Expand Up @@ -49,6 +49,6 @@ mkShell {
fi
# source bazel bash completion
source ${pkgs.bazel}/share/bash-completion/completions/bazel.bash
source ${bazel_4}/share/bash-completion/completions/bazel.bash
'';
}
4 changes: 2 additions & 2 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
MIN_BAZEL_MAJOR=2
MIN_BAZEL_MINOR=1

MAX_BAZEL_MAJOR=3
MAX_BAZEL_MINOR=7
MAX_BAZEL_MAJOR=4
MAX_BAZEL_MINOR=0

set -e

Expand Down

0 comments on commit cf1300c

Please sign in to comment.