From 7d67afe60f706cd936a40324bd4dd251961dfffb Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Fri, 19 Feb 2021 18:07:24 +0100 Subject: [PATCH 1/2] Update to Bazel 4.0.0 --- .ci/bazel-3.7.2-darwin-x86_64.sha256 | 1 - .ci/bazel-3.7.2-linux-x86_64.sha256 | 1 - .ci/bazel-3.7.2-windows-x86_64.exe.sha256 | 1 - .ci/bazel-4.0.0-darwin-x86_64.sha256 | 1 + .ci/bazel-4.0.0-linux-x86_64.sha256 | 1 + .ci/bazel-4.0.0-windows-x86_64.exe.sha256 | 1 + .ci/bazelversion | 2 +- haskell/private/versions.bzl | 2 +- nixpkgs/default.nix | 6 +++--- shell.nix | 4 ++-- start | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) delete mode 100644 .ci/bazel-3.7.2-darwin-x86_64.sha256 delete mode 100644 .ci/bazel-3.7.2-linux-x86_64.sha256 delete mode 100644 .ci/bazel-3.7.2-windows-x86_64.exe.sha256 create mode 100644 .ci/bazel-4.0.0-darwin-x86_64.sha256 create mode 100644 .ci/bazel-4.0.0-linux-x86_64.sha256 create mode 100644 .ci/bazel-4.0.0-windows-x86_64.exe.sha256 diff --git a/.ci/bazel-3.7.2-darwin-x86_64.sha256 b/.ci/bazel-3.7.2-darwin-x86_64.sha256 deleted file mode 100644 index 7ac61c4ff..000000000 --- a/.ci/bazel-3.7.2-darwin-x86_64.sha256 +++ /dev/null @@ -1 +0,0 @@ -80c82e93a12ba30021692b11c78007807e82383a673be1602573b944beb359ab bazel-3.7.2-darwin-x86_64 diff --git a/.ci/bazel-3.7.2-linux-x86_64.sha256 b/.ci/bazel-3.7.2-linux-x86_64.sha256 deleted file mode 100644 index 64c1c3ff3..000000000 --- a/.ci/bazel-3.7.2-linux-x86_64.sha256 +++ /dev/null @@ -1 +0,0 @@ -70dc0bee198a4c3d332925a32d464d9036a831977501f66d4996854ad4e4fc0d bazel-3.7.2-linux-x86_64 diff --git a/.ci/bazel-3.7.2-windows-x86_64.exe.sha256 b/.ci/bazel-3.7.2-windows-x86_64.exe.sha256 deleted file mode 100644 index eed5a9d82..000000000 --- a/.ci/bazel-3.7.2-windows-x86_64.exe.sha256 +++ /dev/null @@ -1 +0,0 @@ -ecb696b1b9c9da6728d92fbfe8410bafb4b3a65c358980e49742233f33f74d10 bazel-3.7.2-windows-x86_64.exe diff --git a/.ci/bazel-4.0.0-darwin-x86_64.sha256 b/.ci/bazel-4.0.0-darwin-x86_64.sha256 new file mode 100644 index 000000000..fc47cac96 --- /dev/null +++ b/.ci/bazel-4.0.0-darwin-x86_64.sha256 @@ -0,0 +1 @@ +349f3c9dd24191369c1073c57cc1386fc3c2d4ad7d44135c3d873c9dc67fae1f bazel-4.0.0-darwin-x86_64 diff --git a/.ci/bazel-4.0.0-linux-x86_64.sha256 b/.ci/bazel-4.0.0-linux-x86_64.sha256 new file mode 100644 index 000000000..106524c6d --- /dev/null +++ b/.ci/bazel-4.0.0-linux-x86_64.sha256 @@ -0,0 +1 @@ +7bee349a626281fc8b8d04a7a0b0358492712377400ab12533aeb39c2eb2b901 bazel-4.0.0-linux-x86_64 diff --git a/.ci/bazel-4.0.0-windows-x86_64.exe.sha256 b/.ci/bazel-4.0.0-windows-x86_64.exe.sha256 new file mode 100644 index 000000000..8aeb31f57 --- /dev/null +++ b/.ci/bazel-4.0.0-windows-x86_64.exe.sha256 @@ -0,0 +1 @@ +43930bbbc8b5d618884ee8145e1ec181760bf9eea42d16217a30381d176e4cf6 bazel-4.0.0-windows-x86_64.exe diff --git a/.ci/bazelversion b/.ci/bazelversion index 0b2eb36f5..fcdb2e109 100644 --- a/.ci/bazelversion +++ b/.ci/bazelversion @@ -1 +1 @@ -3.7.2 +4.0.0 diff --git a/haskell/private/versions.bzl b/haskell/private/versions.bzl index 4d9c6621c..0167bebf3 100644 --- a/haskell/private/versions.bzl +++ b/haskell/private/versions.bzl @@ -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)) diff --git a/nixpkgs/default.nix b/nixpkgs/default.nix index d290e5352..a9a8e927a 100644 --- a/nixpkgs/default.nix +++ b/nixpkgs/default.nix @@ -1,7 +1,7 @@ let - # 2021-02-04 - sha256 = "1bkjh566r1bpbddz6fjhccn872p1dlvg5fwq9j2qdj4b5q2pmljc"; - rev = "24e5fe6075bc7a137bb701eb8a378f5a8689e10d"; + # 2021-02-19 + sha256 = "1fwl898f6wznkjpwq11brgadz6iff5w5f4lwj2l7ax2rz7r03mnn"; + rev = "ad4db3f4d8ae54482c63c31c14921cb73953548d"; in import (fetchTarball { inherit sha256; diff --git a/shell.nix b/shell.nix index 78d394014..9d6a1f86c 100644 --- a/shell.nix +++ b/shell.nix @@ -17,7 +17,7 @@ mkShell { which perl python3 - bazel + bazel_4 jdk11 # For stack_install. stack @@ -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 ''; } diff --git a/start b/start index eecbd76b3..11a40d4ea 100755 --- a/start +++ b/start @@ -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 From 5688d62486abe1e058121bfac61b111e52a00cc2 Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Mon, 22 Feb 2021 12:41:19 +0100 Subject: [PATCH 2/2] Workaround erroneous response file expansion Bazel 4.0.0's own cc_wrapper expands response files. However, it fails to make exceptions for legitimate arguments starting with `@` on macOS, such as `-install_name @rpath/...` or `-rpath @loader_path/...`. We use `-Wl,...` syntax for these arguments as a workaround. --- haskell/private/cc_wrapper.py.tpl | 45 ++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/haskell/private/cc_wrapper.py.tpl b/haskell/private/cc_wrapper.py.tpl index 04aec91d2..61a2c6cc0 100644 --- a/haskell/private/cc_wrapper.py.tpl +++ b/haskell/private/cc_wrapper.py.tpl @@ -46,7 +46,7 @@ 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 @@ -54,6 +54,18 @@ used to avoid command line length limitations. 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 @@ -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): @@ -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 @@ -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. @@ -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) # --------------------------------------------------------------------