git.iko.soy/typeable/nixpkgs
on master help sign in
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

commitb461c9e5bca357737f97e2675d5c25e2ce5903a2 authorClaudio Bley <cbley@exa-online.de> dateMon 1 Feb 2021, 21:56 (6 years ago) parent56c25c5
3 files changed+45−1
pkgs/development/tools/build-managers/bazel/bazel_4/default.nix+10 pkgs/development/tools/build-managers/bazel/bazel_4/no-arc.patch+34 pkgs/top-level/all-packages.nix+1−1
pkgs/development/tools/build-managers/bazel/bazel_4/default.nix+10
@@ -181,6 +181,14 @@ stdenv.mkDerivation rec {
181181 # argument if it's found to be an empty string.
182182 ../trim-last-argument-to-gcc-if-empty.patch
183183
184+ # On Darwin, using clang 6 to build fails because of a linker error (see #105573),
185+ # but using clang 7 fails because libarclite_macosx.a cannot be found when linking
186+ # the xcode_locator tool.
187+ # This patch removes using the -fobjc-arc compiler option and makes the code
188+ # compile without automatic reference counting. Caveat: this leaks memory, but
189+ # we accept this fact because xcode_locator is only a short-lived process used during the build.
190+ ./no-arc.patch
191+
184192 # --experimental_strict_action_env (which may one day become the default
185193 # see bazelbuild/bazel#2574) hardcodes the default
186194 # action environment to a non hermetic value (e.g. "/usr/local/bin").
@@ -389,6 +397,8 @@ stdenv.mkDerivation rec {
389397 src/tools/xcode/stdredirect/BUILD \
390398 tools/osx/BUILD
391399
400+ substituteInPlace scripts/bootstrap/compile.sh --replace ' -mmacosx-version-min=10.9' ""
401+
392402 # nixpkgs's libSystem cannot use pthread headers directly, must import GCD headers instead
393403 sed -i -e "/#include <pthread\/spawn.h>/i #include <dispatch/dispatch.h>" src/main/cpp/blaze_util_darwin.cc
394404
pkgs/development/tools/build-managers/bazel/bazel_4/no-arc.patchnew file+34
@@ -0,0 +1,34 @@
1+--- a/tools/osx/xcode_locator.m 2020-12-10 13:27:29.000000000 +0100
2++++ b/tools/osx/xcode_locator.m 2021-02-01 09:09:32.159557051 +0100
3+@@ -21,10 +21,6 @@
4+ // 6,6.4,6.4.1 = 6.4.1
5+ // 6.3,6.3.0 = 6.3
6+
7+-#if !defined(__has_feature) || !__has_feature(objc_arc)
8+-#error "This file requires ARC support."
9+-#endif
10+-
11+ #import <CoreServices/CoreServices.h>
12+ #import <Foundation/Foundation.h>
13+
14+--- a/tools/osx/xcode_configure.bzl 1980-01-01 01:00:00.000000000 +0100
15++++ b/tools/osx/xcode_configure.bzl 2021-02-01 09:36:57.773418444 +0100
16+@@ -123,7 +123,6 @@
17+ "macosx",
18+ "clang",
19+ "-mmacosx-version-min=10.9",
20+- "-fobjc-arc",
21+ "-framework",
22+ "CoreServices",
23+ "-framework",
24+--- a/tools/osx/BUILD 2021-02-01 11:01:02.191659553 +0100
25++++ b/tools/osx/BUILD 2021-02-01 11:04:29.735071019 +0100
26+@@ -27,7 +27,7 @@
27+ ])
28+
29+ DARWIN_XCODE_LOCATOR_COMPILE_COMMAND = """
30+- /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.9 -fobjc-arc -framework CoreServices \
31++ /usr/bin/xcrun --sdk macosx clang -mmacosx-version-min=10.9 -framework CoreServices \
32+ -framework Foundation -o $@ $<
33+ """
34+
pkgs/top-level/all-packages.nix+1−1
@@ -11740,7 +11740,7 @@ in
1174011740 buildJdk = jdk8_headless;
1174111741 buildJdkName = "jdk8";
1174211742 runJdk = jdk11_headless;
11743− stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv;
11743+ stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv;
1174411744 bazel_self = bazel_4;
1174511745 };
1174611746