Repository navigation
swift: 5.10.1 -> 6.2.4 - #557896
swift: 5.10.1 -> 6.2.4#557896
Conversation
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
732c845 to
a5985da
Compare
booxter
left a comment
There was a problem hiding this comment.
This is impressive work. Love the split of the branch. A lot of it is, frankly, over my head (around bootstrap and such), but I think I found a few bugs on the edges worth taking a look.
So far I was able to build linux swift only (I have relatively weak darwin fleet so I'll have darwin available for me to poke at tomorrow only). So this is very limited look at the actual output.
Also, since you put so much effort into making each commit independently consistent and non-breaking, maybe you'd want to squash those two:
19bb29ce9cc1 swiftPackages_ng: rename to swiftPackages
d2d356b7caac swiftPackages: delete Swift 5.10.1 package set
Since d2d356b7caac breaks the tree; which is then restored to normal by 19bb29ce9cc1.
| let | ||
| # The Swift build system expects to link statically against LLVM. Trying to link to the `libLLVM` shared | ||
| # library causes `swift-frontend` to crash during the build on Linux. | ||
| staticLibllvm = prev.libllvm.override { enableSharedLibraries = false; }; |
There was a problem hiding this comment.
There's probably nothing to do about it, but I will note that it was a bit surprising to see a 15GB+ derivation being pulled for clang. (Most of it is debug.) I assume that's expected.
There was a problem hiding this comment.
The debug symbols are huge. I don’t know how this can be reduced in size, unfortunately. The Swift build on Linux crashes in LLVM assertions when LLVM is dynamically linked.
| ) | ||
|
|
||
| target_link_libraries(FoundationEssentials INTERFACE | ||
| _FoundationICU |
There was a problem hiding this comment.
So I've asked a llm to validate these cmake files: generate linux derivations that rely on them and confirm that they build / link. Here's one that fails:
{ system ? "x86_64-linux" }:
let
pkgs = import ../. { inherit system; };
swiftPackages = pkgs.swiftPackages;
cmakeLists = pkgs.writeText "CMakeLists.txt" ''
cmake_minimum_required(VERSION 3.26)
project(FoundationEssentialsReproducer LANGUAGES Swift)
find_package(SwiftFoundation CONFIG REQUIRED)
add_executable(reproducer main.swift)
target_link_libraries(reproducer PRIVATE FoundationEssentials)
'';
swiftSource = pkgs.writeText "main.swift" ''
import FoundationEssentials
let url = URL(string: "https://example.invalid/swift-6.2")!
print(url.absoluteString)
'';
in
pkgs.stdenv.mkDerivation {
pname = "foundation-essentials-cmake-reproducer";
version = "0";
dontUnpack = true;
nativeBuildInputs = [
pkgs.cmake
pkgs.ninja
swiftPackages.swift
];
buildInputs = [
swiftPackages.swift-collections
swiftPackages.swift-foundation-icu
swiftPackages.swift-foundation
];
configurePhase = ''
runHook preConfigure
mkdir source build
cp ${cmakeLists} source/CMakeLists.txt
cp ${swiftSource} source/main.swift
cmake -S source -B build -G Ninja
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
cmake --build build --verbose
runHook postBuild
'';
installPhase = ''
mkdir -p "$out/bin"
cp build/reproducer "$out/bin/"
'';
}
log:
Running phase: configurePhase
-- The Swift compiler identification is Apple 6.2.4
-- Check for working Swift compiler: /nix/store/2wixmzgbg0nh5ir6y5ipc86y4cndd8g3-swift-6.2.4/bin/swiftc
-- Check for working Swift compiler: /nix/store/2wixmzgbg0nh5ir6y5ipc86y4cndd8g3-swift-6.2.4/bin/swiftc - works
CMake Warning at /nix/store/bdm8wbfjhd42xxx1r4b133p1i0gq2kky-swift-foundation-6.2.4-dev/lib/cmake/SwiftFoundation/SwiftFoundationConfig.cmake:12 (find_package):
By not providing "Find_FoundationICU.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"_FoundationICU", but CMake did not find one.
Could not find a package configuration file provided by "_FoundationICU"
with any of the following names:
_FoundationICU.cps
_foundationicu.cps
_FoundationICUConfig.cmake
_foundationicu-config.cmake
Add the installation prefix of "_FoundationICU" to CMAKE_PREFIX_PATH or set
"_FoundationICU_DIR" to a directory containing one of the above files. If
"_FoundationICU" provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
CMakeLists.txt:4 (find_package)
-- Configuring done (1.0s)
-- Generating done (0.0s)
-- Build files have been written to: /build/build
Running phase: buildPhase
Change Dir: '/build/build'
Run Build Command(s): /nix/store/6ji6bq0si2j8ibdrxqgcmh1cw0wmdiyk-ninja-1.13.2/bin/ninja -v
[1/1] : && /nix/store/2wixmzgbg0nh5ir6y5ipc86y4cndd8g3-swift-6.2.4/bin/swiftc -j 32 -num-threads 32 -emit-executable -o reproducer -emit-dependencies -output-file-map CMakeFiles/reproducer.dir//output-file-map.json -I /nix/store/bdm8wbfjhd42xxx1r4b133p1i0gq2kky-swift-foundation-6.2.4-dev/lib/swift -I /nix/store/bdm8wbfjhd42xxx1r4b133p1i0gq2kky-swift-foundation-6.2.4-dev/lib/swift/linux /build/source/main.swift -L /nix/store/ifrjb0yyk5xfw307k2ij2mzxjxfiz7bj-swift-foundation-6.2.4/lib -Xlinker -rpath -Xlinker /nix/store/ifrjb0yyk5xfw307k2ij2mzxjxfiz7bj-swift-foundation-6.2.4/lib /nix/store/ifrjb0yyk5xfw307k2ij2mzxjxfiz7bj-swift-foundation-6.2.4/lib/libFoundationEssentials.so -l_FoundationICU && :
FAILED: [code=1] reproducer CMakeFiles/reproducer.dir/main.swift.o
: && /nix/store/2wixmzgbg0nh5ir6y5ipc86y4cndd8g3-swift-6.2.4/bin/swiftc -j 32 -num-threads 32 -emit-executable -o reproducer -emit-dependencies -output-file-map CMakeFiles/reproducer.dir//output-file-map.json -I /nix/store/bdm8wbfjhd42xxx1r4b133p1i0gq2kky-swift-foundation-6.2.4-dev/lib/swift -I /nix/store/bdm8wbfjhd42xxx1r4b133p1i0gq2kky-swift-foundation-6.2.4-dev/lib/swift/linux /build/source/main.swift -L /nix/store/ifrjb0yyk5xfw307k2ij2mzxjxfiz7bj-swift-foundation-6.2.4/lib -Xlinker -rpath -Xlinker /nix/store/ifrjb0yyk5xfw307k2ij2mzxjxfiz7bj-swift-foundation-6.2.4/lib /nix/store/ifrjb0yyk5xfw307k2ij2mzxjxfiz7bj-swift-foundation-6.2.4/lib/libFoundationEssentials.so -l_FoundationICU && :
error: link command failed with exit code 1 (use -v to see invocation)
/nix/store/5pa1282x1sasbwhmnah6bny1g9pc2lj1-binutils-2.46/bin/ld.bfd: cannot find -l_FoundationICU: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
How are these files produced? Are they supposed to match some upstream source files? (Wonder if there's a way to sync them.) Perhaps we need some test cases that would build a test program via cmake and confirm the result is legit?
There was a problem hiding this comment.
How are these files produced? Are they supposed to match some upstream source files?
Upstream assumes that you are building everything next to each other. These were hand-written to provide enough glue to build the Swift toolchain because the upstream files are not really suitable for our purpose.
I can look at fixing this one when I have time later tonight or tomorrow, but it’s not really intended for packages outside the toolchain to use these. There’s no way to stop people from doing that short of removing the packages from the package set, which I’d rather not do if possible.
|
I’ll look at the others later when I have time tonight or tomorrow. During my work on adding 6.3.3, I found a bug in the definition of
I had removed all references to |
|
I was building this series (ported to Not sure what it means. |
2e4d056 to
d5fa3c4
Compare
|
@booxter I believe I’ve addressed all of your feedback. Thank you!
Is your store case-sensitive or case-insensitive? Mine is case-sensitive, I see the following when I check the contents of I’m already using |
d5fa3c4 to
6eebcce
Compare
f066192 to
3c11765
Compare
|
Let’s merge this thing and make way for Swift 6.3.3. |
|
|
It doesn't seem to build, though: https://hydra.nixos.org/build/346563481/step/3/log/tail |
Huh. That’s interesting. It was building at the time this merged, and my Swift 6.3.3 and Swift 6.4 branches are building on staging as of this Sunday morning. Was there a Glibc bump in the last few days? Oh. #557451 was merged yesterday. That’s probably it. I’ll work on a patch. |
with swift 6 merged we can finally update this NixOS#557896
with swift 6 merged we can finally update this NixOS#557896 use the new swiftpm machinery: https://github.com/NixOS/nixpkgs/blob/staging-next/doc/languages-frameworks/swift.section.md#packaging-with-swiftpm-ssec-swift-packaging-with-swiftpm
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
According to https://nixpk.gs/pr-tracker.html?pr=557896, this PR has finally landed in unstable! Thank you so much for your work! |
This has been a long time coming. I seem to have a knack for volunteering to do big rewrites (the Darwin stdenv, the SDK, and now Swift). 😅
I apologize this took so long. As I discussed on Bluesky, it was a cycle of burnout and long cycles. However, it’s ready, and the foundation is set to make Swift easier to use in Nixpkgs and easier to update and maintain.
I want to thank everyone who joined https://matrix.to/#/%23nixpkgs-swift:matrix.org as well as here and on Discourse who tested, reviewed, and/or provided feedback (@jen20, @booxter, and others). I also want to thank and @lucasly-ba in particular for demonstrating that it is possible to build Swift from an usptream toolchain using a sysroot even if that turned out not to have the right set of trade-offs for building Swift in Nixpkgs.
And now for the changes themselves …
This PR is a rewrite of the Swift packaging and an update of Swift to Swift 6.2.4. It replaces the single
compilerderivation that builds LLVM and Swift together with several that build everything separately. The Swift LLVM fork leverages the LLVM packaging already done in Nixpkgs. The Swift bootstrap is now implemented in Nix. The stdlib has been split out into its own package. It should interact with Nixpkgs tooling much better than before.For the most part, it is compatible with the old Swift packaging except as noted in the packaging changes listed below.
https://www.swift.org/blog/announcing-swift-6/
https://www.swift.org/blog/swift-6.1-released/
https://www.swift.org/blog/swift-6.2-released/
Note: This PR has a large number of changes because I wanted to land each part of the rewrite as it is needed, but I also did not want to break eval or existing builds. Until 0c7f9f2, the default Swift is 5.10.1. I confirmed every commit evals using the following
jj runinvocation. It took a while, but it confirmed no evaluation errors. I confirmed that new packages built by doingjj new <change-id>and then manuallynix building them.Changes to packaging
swiftPackages.swiftis now a Swift toolchain. It is no longer wrapped. This is a breaking change, but it’s likely not one that most packages will notice.swiftPackages.swiftnow has (more) tests. Yay, tests!Dispatch,Foundation, andXCTesthave been moved to their upstream names. The old names are available as aliases. Cleanup was done to prevent warnings (and eval failures in CI) in Nixpkgs.swiftPackages.stdlib. The stubs and modules have been removed from the Darwin SDKs. To build Swift applications, you must use the stdlib package, which is part of the toolchain.stdenvwhen building Swift packages. This was a common footgun. The defaultstdenvwill just work because Swift finds and usesclangin the toolchain.fetchSwiftPMDepsFOD has been added to make packaging Swift dependencies a lot easier. In most cases, you don’t have to do anything. Just add it to your package, and the dependencies will be made available.Other than
age-plugin-se, which used a custom vendoring method, I did not convert any packages outside of the Swift package set to usefetchSwiftPMDeps.swiftpm2nixis still supported and works. It was updated to use the same vendoring method asfetchSwiftPMDeps. Maintainers who would prefer to usefetchSwiftPMDepscan update their packages accordingly once this is merged.Limitations
Future directions
sourcekit-lspcrashes when opening.swiftfiles in VSCode #331943 are still issues.Fixes/closes
dockutilpackage triggers a swift recompilation on macOS #346866Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.