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
emilazy
left a comment
There was a problem hiding this comment.
Not really qualified to review this, but generally LGTM. Love to see those comments about our weird build environment disappear.
There was a problem hiding this comment.
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.
It also defaults to 10.15 when building on Linux (or should).
There was a problem hiding this comment.
I don’t really understand this.
There was a problem hiding this comment.
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.
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.
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
emilazy
left a comment
There was a problem hiding this comment.
I think I understand this about as well as I ever will.
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
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 = relaxedsandbox = truenix-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.