diff --git a/pkgs/development/tools/build-managers/bazel/bazel_3/default.nix b/pkgs/development/tools/build-managers/bazel/bazel_3/default.nix index 5e5686ea20d..37afb129867 100644 --- a/pkgs/development/tools/build-managers/bazel/bazel_3/default.nix +++ b/pkgs/development/tools/build-managers/bazel/bazel_3/default.nix @@ -176,6 +176,14 @@ stdenv.mkDerivation rec { # argument if it's found to be an empty string. ../trim-last-argument-to-gcc-if-empty.patch + # On Darwin, using clang 6 to build fails because of a linker error (see #105573), + # but using clang 7 fails because libarclite_macosx.a cannot be found when linking + # the xcode_locator tool. + # This patch removes using the -fobjc-arc compiler option and makes the code + # compile without automatic reference counting. Caveat: this leaks memory, but + # we neglect this fact. + ./no-arc.patch + # --experimental_strict_action_env (which may one day become the default # see bazelbuild/bazel#2574) hardcodes the default # action environment to a non hermetic value (e.g. "/usr/local/bin"). @@ -371,6 +379,8 @@ stdenv.mkDerivation rec { src/tools/xcode/stdredirect/BUILD \ tools/osx/BUILD + substituteInPlace scripts/bootstrap/compile.sh --replace ' -mmacosx-version-min=10.9' "" + # nixpkgs's libSystem cannot use pthread headers directly, must import GCD headers instead sed -i -e "/#include /i #include " src/main/cpp/blaze_util_darwin.cc diff --git a/pkgs/development/tools/build-managers/bazel/bazel_3/no-arc.patch b/pkgs/development/tools/build-managers/bazel/bazel_3/no-arc.patch new file mode 100644 index 00000000000..012e613c2f1 --- /dev/null +++ b/pkgs/development/tools/build-managers/bazel/bazel_3/no-arc.patch @@ -0,0 +1,34 @@ +--- a/tools/osx/xcode_locator.m 2020-12-10 13:27:29.000000000 +0100 ++++ b/tools/osx/xcode_locator.m 2021-02-01 09:09:32.159557051 +0100 +@@ -21,10 +21,6 @@ + // 6,6.4,6.4.1 = 6.4.1 + // 6.3,6.3.0 = 6.3 + +-#if !defined(__has_feature) || !__has_feature(objc_arc) +-#error "This file requires ARC support." +-#endif +- + #import + #import + +--- a/tools/osx/xcode_configure.bzl 1980-01-01 01:00:00.000000000 +0100 ++++ b/tools/osx/xcode_configure.bzl 2021-02-01 09:36:57.773418444 +0100 +@@ -123,7 +123,6 @@ + "macosx", + "clang", + "-mmacosx-version-min=10.9", +- "-fobjc-arc", + "-framework", + "CoreServices", + "-framework", +--- a/tools/osx/BUILD 2021-02-01 11:01:02.191659553 +0100 ++++ b/tools/osx/BUILD 2021-02-01 11:04:29.735071019 +0100 +@@ -27,7 +27,7 @@ + ]) + + DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """ +- /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices \ ++ /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.9 -framework CoreServices \ + -framework Foundation -o $@ $< + """ + diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b09a40a550b..76cdb38c1f3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11680,7 +11680,7 @@ in buildJdk = jdk11_headless; buildJdkName = "java11"; runJdk = jdk11_headless; - stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv; + stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv; bazel_self = bazel_3; };