-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
swift: fix build with the new SDK pattern #346947
Conversation
0a52694
to
01991c1
Compare
01991c1
to
d2848dd
Compare
ee7fb7e
to
183877a
Compare
a240201
to
4112f1a
Compare
Swift’s build makes a few assumptions about how the SDK is set up that are not true anymore with the new SDK. Fix it to find the SDK at `$SDKROOT` and copy additional stubs it needs to bootstrap.
libarclite is needed to support ARC on very old deployment targets (10.10 and older). None of these deployment targets are supported deployment targets in nixpkgs, especially for Swift. This removes the need to package the command-line tools executables.
Swift releases are associated with particular Darwin SDK versions. They don’t _have_ to use that version, but it makes sense to use that version by default. The deployment target is set to the supported Swift minimum versions. Unlike C and C++, Swift requires you to availability annotations, so propagating a newer SDK should be safe.
8d5d373
to
849fb99
Compare
4112f1a
to
a1adff0
Compare
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.
Not really qualified to review this, but generally LGTM. Love to see those comments about our weird build environment disappear.
deploymentVersion = | ||
if lib.versionOlder (targetPlatform.darwinMinVersion or "0") "10.15" then | ||
"10.15" | ||
else | ||
targetPlatform.darwinMinVersion; |
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 think this is equivalent to deploymentVersion = "10.15";
, but it’s fine (and will go away in 25.05 anyway).
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.
It also defaults to 10.15 when building on Linux (or should).
# Make empty to avoid adding the SDK’s modules in the bootstrap wrapper. Otherwise, the SDK conflicts with the | ||
# shims the wrapper tries to build. | ||
darwinMinVersion="" substituteAll '${../wrapper/wrapper.sh}' "$out" |
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 don’t really understand this.
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.
The wrapper uses darwinMinVersion
to detect whether it is targeting Linux or Darwin. On Darwin, it will add the SDK to NIX_CFLAGS_COMPILE
. Setting it to empty triggers the Linux behavior (no setting), which is what we want because the full SDK breaks the Swift bootstrap.
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 see, I guess because they expect people to be using the system Swift for bootstrap on macOS?
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.
Upstream uses a Python script to manage the bootstrap. I don’t know the specifics, but the nixpkgs derivation is trying to recreate what it does.
a1adff0
to
e3f2829
Compare
These are no longer needed with the new Darwin SDK. xcbuild will automatically use the correct SDK for the stdenv.
849fb99
to
f4af7ea
Compare
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 think I understand this about as well as I ever will.
…h64-darwin - Switch to new appke SDK pattern, NixOS#346947 - Build from source for aarch64-darwin * Use llvmPackages_19 on aarch64-darwin for `ptrauth.h` support * Setup unwrapped clang to build the arm64e scripting addition - Use nix-update-script for passthru.updateScript
…h64-darwin - Switch to new appke SDK pattern, NixOS#346947 - Build from source for aarch64-darwin * Use llvmPackages_19 on aarch64-darwin for `ptrauth.h` support * Setup unwrapped clang to build the arm64e scripting addition - Use nix-update-script for passthru.updateScript - Add azuwis as maintainer
…h64-darwin - Switch to new appke SDK pattern, NixOS#346947 - Build from source for aarch64-darwin * Use llvmPackages_19 on aarch64-darwin for `ptrauth.h` support * Setup unwrapped clang to build the arm64e scripting addition - Use nix-update-script for passthru.updateScript - Add azuwis as maintainer
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/title-the-darwin-sdks-have-been-updated/55295/1 |
Swift depends on how the old SDK pattern was implemented (e.g., that only the requested framework dependencies would be available). This PR updates Swift to build in a way that’s compatible with the new pattern, uses the same SDK that Swift 5.8 expects to use, and propagates it to make sure packages using Swift have at least the right SDK version.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.