Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darwin-stdenv: revert NIX_CC_NO_RESPONSE_FILE logic #245640

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 17 additions & 48 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ let
isBuiltByBootstrapFilesCompiler =
pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc;

commonPreHook = pkgs: lib.optionalString (pkgs.darwin.system_cmds != null) ''
# Only use a response file on older systems with a small ARG_MAX (less than 1 MiB).
export NIX_CC_USE_RESPONSE_FILE=$(( "$("${lib.getBin pkgs.darwin.system_cmds}/bin/getconf" ARG_MAX)" < 1048576 ))
export NIX_LD_USE_RESPONSE_FILE=$NIX_CC_USE_RESPONSE_FILE
'' + ''
commonPreHook = ''
export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1}
export NIX_ENFORCE_PURITY=''${NIX_ENFORCE_PURITY-1}
export NIX_IGNORE_LD_THROUGH_GCC=1
Expand Down Expand Up @@ -166,7 +162,7 @@ let
# dependencies on the bootstrapTools in the final stdenv.
dontPatchShebangs=1
'' + ''
${commonPreHook prevStage}
${commonPreHook}
${extraPreHook}
'' + lib.optionalString (prevStage.darwin ? locale) ''
export PATH_LOCALE=${prevStage.darwin.locale}/share/locale
Expand Down Expand Up @@ -216,7 +212,6 @@ in
print-reexports = null;
rewrite-tbd = null;
sigtool = null;
system_cmds = null;
CF = null;
Libsystem = null;
};
Expand Down Expand Up @@ -300,27 +295,6 @@ in
rewrite-tbd = bootstrapTools;

sigtool = bootstrapTools;

# The bootstrap only needs `getconf` from system_cmds, and it only needs to be able to
# query `ARG_MAX`. Using a small value here should be fine for the initial stage 1 build.
system_cmds = self.stdenv.mkDerivation {
name = "bootstrap-stage0-system_cmds";
buildCommand = ''
mkdir -p "$out/bin"
cat <<block > "$out/bin/getconf"
#!${bootstrapTools}/bin/bash
case "\$1" in
ARG_MAX)
echo "262144"
;;
*)
exit 1
esac
block
chmod a+x "$out/bin/getconf"
'';
passthru.isFromBootstrapFiles = true;
};
} // lib.optionalAttrs (! useAppleSDKLibs) {
CF = self.stdenv.mkDerivation {
name = "bootstrap-stage0-CF";
Expand Down Expand Up @@ -453,7 +427,7 @@ in
assert lib.all isFromBootstrapFiles (with prevStage; [ bash coreutils cpio gnugrep pbzx ]);

assert lib.all isFromBootstrapFiles (with prevStage.darwin; [
binutils-unwrapped cctools print-reexports rewrite-tbd sigtool system_cmds
binutils-unwrapped cctools print-reexports rewrite-tbd sigtool
]);

assert (! useAppleSDKLibs) -> lib.all isFromBootstrapFiles (with prevStage.darwin; [ CF Libsystem ]);
Expand Down Expand Up @@ -486,8 +460,6 @@ in
python3 = super.python3Minimal;

darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
inherit (prevStage.darwin) system_cmds;

signingUtils = prevStage.darwin.signingUtils.override {
inherit (selfDarwin) sigtool;
};
Expand Down Expand Up @@ -536,7 +508,7 @@ in
'';
})

# Build sysctl, system_cmds and Python for use by LLVM’s check phase. These must be built in their
# Build sysctl and Python for use by LLVM’s check phase. These must be built in their
# own stage, or an infinite recursion results on x86_64-darwin when using the source-based SDK.
(prevStage:
# previous stage1 stdenv:
Expand All @@ -553,8 +525,6 @@ in
assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool
]);
assert lib.all isFromBootstrapFiles (with prevStage.darwin; [ system_cmds ]);

assert (! useAppleSDKLibs) -> lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [ CF Libsystem configd ]);
assert useAppleSDKLibs -> lib.all isFromNixpkgs (with prevStage.darwin; [ CF Libsystem libobjc]);
assert lib.all isFromNixpkgs (with prevStage.darwin; [ dyld launchd xnu ]);
Expand Down Expand Up @@ -651,7 +621,7 @@ in
]);

assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool system_cmds
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool
]);

assert (! useAppleSDKLibs) -> lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [ CF Libsystem configd ]);
Expand Down Expand Up @@ -679,8 +649,7 @@ in
darwin = super.darwin.overrideScope (_: superDarwin: {
inherit (prevStage.darwin)
CF Libsystem configd darwin-stubs dyld launchd libclosure libdispatch libobjc
locale objc4 postLinkSignHook print-reexports rewrite-tbd signingUtils sigtool
system_cmds;
locale objc4 postLinkSignHook print-reexports rewrite-tbd signingUtils sigtool;

# Avoid building unnecessary Python dependencies due to building LLVM manpages.
cctools-llvm = superDarwin.cctools-llvm.override { enableManpages = false; };
Expand Down Expand Up @@ -749,7 +718,7 @@ in
]);

assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool system_cmds
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool
]);

assert (! useAppleSDKLibs) -> lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [ CF Libsystem configd ]);
Expand Down Expand Up @@ -786,7 +755,7 @@ in
darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
inherit (prevStage.darwin)
CF binutils-unwrapped cctools configd darwin-stubs launchd libobjc libtapi locale
objc4 print-reexports rewrite-tbd signingUtils sigtool system_cmds;
objc4 print-reexports rewrite-tbd signingUtils sigtool;
});

llvmPackages = super.llvmPackages // (
Expand Down Expand Up @@ -848,7 +817,7 @@ in
]);

assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool system_cmds
binutils-unwrapped cctools locale libtapi print-reexports rewrite-tbd sigtool
]);

assert (! useAppleSDKLibs) -> lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [ CF configd ]);
Expand Down Expand Up @@ -882,7 +851,7 @@ in
darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
inherit (prevStage.darwin)
Libsystem configd darwin-stubs launchd locale print-reexports rewrite-tbd
signingUtils sigtool system_cmds;
signingUtils sigtool;

# Rewrap binutils so it uses the rebuilt Libsystem.
binutils = superDarwin.binutils.override {
Expand Down Expand Up @@ -971,7 +940,7 @@ in
]);

assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [
locale print-reexports rewrite-tbd sigtool system_cmds
locale print-reexports rewrite-tbd sigtool
]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.darwin; [
binutils-unwrapped cctools libtapi
Expand Down Expand Up @@ -1011,7 +980,7 @@ in
inherit (prevStage.darwin)
CF Libsystem binutils binutils-unwrapped cctools cctools-llvm cctools-port configd
darwin-stubs dyld launchd libclosure libdispatch libobjc libtapi locale objc4
postLinkSignHook print-reexports rewrite-tbd signingUtils sigtool system_cmds;
postLinkSignHook print-reexports rewrite-tbd signingUtils sigtool;
});

llvmPackages = super.llvmPackages // (
Expand Down Expand Up @@ -1051,7 +1020,7 @@ in
]);

assert lib.all isBuiltByBootstrapFilesCompiler (with prevStage.darwin; [
locale print-reexports rewrite-tbd sigtool system_cmds
locale print-reexports rewrite-tbd sigtool
]);
assert lib.all isBuiltByNixpkgsCompiler (with prevStage.darwin; [
binutils-unwrapped cctools libtapi
Expand Down Expand Up @@ -1191,7 +1160,7 @@ in
]);

assert lib.all isBuiltByNixpkgsCompiler (with prevStage.darwin; [
binutils-unwrapped cctools libtapi locale print-reexports rewrite-tbd sigtool system_cmds
binutils-unwrapped cctools libtapi locale print-reexports rewrite-tbd sigtool
]);

assert (! useAppleSDKLibs) -> lib.all isBuiltByNixpkgsCompiler (with prevStage.darwin; [ CF Libsystem configd ]);
Expand Down Expand Up @@ -1226,7 +1195,8 @@ in

inherit config;

preHook = (commonPreHook prevStage) + ''
preHook = ''
${commonPreHook}
stripDebugFlags="-S" # llvm-strip does not support "-p" for Mach-O
export PATH_LOCALE=${prevStage.darwin.locale}/share/locale
'';
Expand Down Expand Up @@ -1324,7 +1294,6 @@ in
dyld
libtapi
locale
system_cmds
]
++ lib.optional useAppleSDKLibs [ objc4 ]
++ lib.optionals doSign [ postLinkSignHook sigtool signingUtils ]);
Expand All @@ -1341,7 +1310,7 @@ in

darwin = super.darwin.overrideScope (_: _: {
inherit (prevStage.darwin)
CF ICU Libsystem darwin-stubs dyld locale libobjc libtapi system_cmds xnu;
CF ICU Libsystem darwin-stubs dyld locale libobjc libtapi xnu;
} // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
inherit (prevStage.darwin) binutils binutils-unwrapped cctools-llvm cctools-port;
});
Expand Down