about summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers/bazel
diff options
context:
space:
mode:
authorClaudio Bley <cbley@exa-online.de>2021-02-01 21:56:51 +0100
committerDmitry Ivankov <divanorama@gmail.com>2021-02-04 20:31:43 +0100
commitb461c9e5bca357737f97e2675d5c25e2ce5903a2 (patch)
treee8e7f6771ed109d96dace1fa2433638bc7f66463 /pkgs/development/tools/build-managers/bazel
parent56c25c56539ea6c5accfb75dc443cd049cfe6101 (diff)
bazel_4: Fix build on darwin
* use default stdenv (clang 7)
* add no-arc.patch to make the xcode_locate tool compile without libarc-lite
* remove the `-mmacosx-version-min=10.9` flag from the bootstrap compile script
Diffstat (limited to 'pkgs/development/tools/build-managers/bazel')
-rw-r--r--pkgs/development/tools/build-managers/bazel/bazel_4/default.nix10
-rw-r--r--pkgs/development/tools/build-managers/bazel/bazel_4/no-arc.patch34
2 files changed, 44 insertions, 0 deletions
diff --git a/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix b/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix
index 9a9648715db63..137e5639f3711 100644
--- a/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix
+++ b/pkgs/development/tools/build-managers/bazel/bazel_4/default.nix
@@ -181,6 +181,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 accept this fact because xcode_locator is only a short-lived process used during the build.
+    ./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").
@@ -389,6 +397,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 <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc
 
diff --git a/pkgs/development/tools/build-managers/bazel/bazel_4/no-arc.patch b/pkgs/development/tools/build-managers/bazel/bazel_4/no-arc.patch
new file mode 100644
index 0000000000000..012e613c2f19e
--- /dev/null
+++ b/pkgs/development/tools/build-managers/bazel/bazel_4/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 <CoreServices/CoreServices.h>
+ #import <Foundation/Foundation.h>
+ 
+--- 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 $@ $<
+ """
+