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: propagate sdkRoot via extraBuildInputs #308366

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
12 changes: 4 additions & 8 deletions pkgs/os-specific/darwin/apple-sdk/sdkRoot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,24 @@ runCommand "sdkroot-${sdkVersion}" { } ''

install -D '${../../../build-support/setup-hooks/role.bash}' "$out/nix-support/setup-hook"
cat >> "$out/nix-support/setup-hook" <<-hook
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we're dropping the exception when the hook isn't a build-time dependency and we're not doing a native compile?

Seems like a good thing to have it apply consistently.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be depsHostTarget (i.e., a buildInput), but the hook wasn’t being run unless I took this out. The doc seems to suggest it should work, but maybe I was doing something wrong.

# See comments in cc-wrapper's setup hook. This works exactly the same way.
#
[[ -z \''${strictDeps-} ]] || (( "\$hostOffset" < 0 )) || return 0

sdkRootHook() {
# See ../../../build-support/setup-hooks/role.bash
local role_post
getHostRoleEnvHook

# Only set the SDK root if one has not been set via this hook or some other means.
if [[ ! \$NIX_CFLAGS_COMPILE =~ isysroot ]]; then
local cflagsVar=NIX_CFLAGS_COMPILE\''${role_post}
if [[ ! \''${!cflagsVar} =~ isysroot ]]; then
export NIX_CFLAGS_COMPILE\''${role_post}+=' -isysroot $out/${sdkName}.sdk'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to reuse the cflagsVar here or can you not use an indirect reference with export?

fi
}

# See ../../../build-support/setup-hooks/role.bash
getTargetRole

Comment on lines 56 to 58
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# See ../../../build-support/setup-hooks/role.bash
getTargetRole

If the below is correct I believe this no longer serves a purpose. Actually seems to be redundant even without the change from target to host offset because this sets role_post, which is unset right after.

addEnvHooks "\$targetOffset" sdkRootHook
addEnvHooks "\$hostOffset" sdkRootHook
toonn marked this conversation as resolved.
Show resolved Hide resolved

# No local scope in sourced file
unset -v role_post
unset -v cflagsVar role_post
hook
''
15 changes: 7 additions & 8 deletions pkgs/stdenv/darwin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ let

inherit config;

extraBuildInputs = [ prevStage.darwin.CF ];
extraNativeBuildInputs = extraNativeBuildInputs
++ [ prevStage.darwin.apple_sdk.sdkRoot ];
extraBuildInputs = [ prevStage.darwin.CF prevStage.darwin.apple_sdk.sdkRoot ];
extraNativeBuildInputs = extraNativeBuildInputs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially use inherit?


preHook = lib.optionalString (!isBuiltByNixpkgsCompiler bash) ''
# Don't patch #!/interpreter because it leads to retained
Expand Down Expand Up @@ -671,7 +670,7 @@ in
# libc++, and libc++abi do not need CoreFoundation. Avoid propagating the CF from prior
# stages to the final stdenv via rpath by dropping it from `extraBuildInputs`.
stdenvNoCF = self.stdenv.override {
extraBuildInputs = [ ];
extraBuildInputs = [ prevStage.darwin.apple_sdk.sdkRoot ];
};

libcxxBootstrapStdenv = self.overrideCC stdenvNoCF (self.llvmPackages.clangNoCompilerRtWithLibc.override {
Expand Down Expand Up @@ -885,7 +884,7 @@ in
compiler-rt = superLib.compiler-rt.override ({
inherit (self.llvmPackages) libllvm;
stdenv = self.stdenv.override {
extraBuildInputs = [ self.darwin.CF ];
extraBuildInputs = [ self.darwin.CF prevStage.darwin.apple_sdk.sdkRoot ];
};
});
});
Expand All @@ -899,7 +898,7 @@ in
stdenv =
let
stdenvNoCF = super.stdenv.override {
extraBuildInputs = [ ];
extraBuildInputs = [ prevStage.darwin.apple_sdk.sdkRoot ];
};
in
self.overrideCC stdenvNoCF (self.llvmPackages.clangNoCompilerRtWithLibc.override {
Expand Down Expand Up @@ -1230,9 +1229,9 @@ in

extraNativeBuildInputs = lib.optionals localSystem.isAarch64 [
prevStage.updateAutotoolsGnuConfigScriptsHook
] ++ [ prevStage.darwin.apple_sdk.sdkRoot ];
];

extraBuildInputs = [ prevStage.darwin.CF ];
extraBuildInputs = [ prevStage.darwin.CF prevStage.darwin.apple_sdk.sdkRoot ];

inherit cc;

Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/darwin-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impure-cmds // appleSourcePackages // chooseLibs // {
inherit apple_sdk apple_sdk_10_12 apple_sdk_11_0;

stdenvNoCF = stdenv.override {
extraBuildInputs = [];
extraBuildInputs = [ apple_sdk.sdkRoot ];
};

binutils-unwrapped = callPackage ../os-specific/darwin/binutils {
Expand Down
Loading