-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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
stdenv: make darwin builds reproducable #77632
Changes from all commits
a826b49
6567823
9b57984
b984c22
68513e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
{ stdenv, fetchurl, xar, cpio, pkgs, python3, pbzx, lib }: | ||
|
||
let version = "10.12"; in | ||
|
||
# Ensure appleSdkVersion is up to date. | ||
assert stdenv.isDarwin -> stdenv.appleSdkVersion == version; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The attribute is macOS specific, without the condition evaluating darwin only packages on linux fails on the assertion instead of meta.platforms with a nice message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I was trying to ask is: if |
||
|
||
let | ||
# sadly needs to be exported because security_tool needs it | ||
sdk = stdenv.mkDerivation rec { | ||
version = "10.12"; | ||
pname = "MacOS_SDK"; | ||
inherit version; | ||
|
||
# This URL comes from https://swscan.apple.com/content/catalogs/others/index-10.12.merged-1.sucatalog, which we found by: | ||
# 1. Google: site:swscan.apple.com and look for a name that seems appropriate for your version | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
{ lib | ||
, localSystem, crossSystem, config, overlays, crossOverlays ? [] | ||
|
||
# The version of darwin.apple_sdk used for sources provided by apple. | ||
, appleSdkVersion ? "10.12" | ||
# Minimum required macOS version, used both for compatibility as well as reproducability. | ||
, macosVersionMin ? "10.12" | ||
# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools | ||
, bootstrapFiles ? let | ||
fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> { | ||
|
@@ -28,15 +31,19 @@ let | |
]; | ||
in rec { | ||
commonPreHook = '' | ||
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}" | ||
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" | ||
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 | ||
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" | ||
export MACOSX_DEPLOYMENT_TARGET=10.12 | ||
export SDKROOT= | ||
export CMAKE_OSX_ARCHITECTURES=x86_64 | ||
|
||
# Ensure consistent LC_VERSION_MIN_MACOSX and remove LC_UUID. | ||
export MACOSX_DEPLOYMENT_TARGET=${macosVersionMin} | ||
export NIX_LDFLAGS+=" -macosx_version_min ${macosVersionMin} -sdk_version ${appleSdkVersion} -no_uuid" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how the linker works when you pass multiple values here. For instance, is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Alltho since it looks like the compiler always adds the flag based on the variable, overriding this original one, it's not really necessary. Added it just in case but should be fine to leave out if you're concerned about it. |
||
|
||
# Workaround for https://openradar.appspot.com/22671534 on 10.11. | ||
export gl_cv_func_getcwd_abort_bug=no | ||
|
||
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making this a space is kind of hacky, but I think it is because of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but doesn't that do the opposite of what we want here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docs say that
So yeah it sounds like the space is needed |
||
''; | ||
|
||
bootstrapTools = derivation { | ||
|
@@ -130,8 +137,7 @@ in rec { | |
__extraImpureHostDeps = commonImpureHostDeps; | ||
|
||
extraAttrs = { | ||
inherit platform; | ||
parent = last; | ||
inherit macosVersionMin appleSdkVersion platform; | ||
}; | ||
overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; }; | ||
}; | ||
|
@@ -400,9 +406,9 @@ in rec { | |
extraBuildInputs = [ pkgs.darwin.CF ]; | ||
|
||
extraAttrs = { | ||
inherit platform bootstrapTools; | ||
libc = pkgs.darwin.Libsystem; | ||
libc = pkgs.darwin.Libsystem; | ||
shellPackage = pkgs.bash; | ||
inherit macosVersionMin appleSdkVersion platform bootstrapTools; | ||
}; | ||
|
||
allowedRequisites = (with pkgs; [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this isn't needed? How does CMake choose this value when it's unset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I understand this correctly this was equivalent to unsetting MACOSX_DEPLOYMENT_TARGET from the stdenv.