1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-03-06 23:31:34 +00:00

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
This commit is contained in:
Claudio Bley 2021-02-01 21:56:51 +01:00 committed by Dmitry Ivankov
parent 56c25c5653
commit b461c9e5bc
3 changed files with 45 additions and 1 deletions

View file

@ -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

View file

@ -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 $@ $<
"""

View file

@ -11740,7 +11740,7 @@ in
buildJdk = jdk8_headless;
buildJdkName = "jdk8";
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_4;
};