I am experiencing a build issue with the swift-6.0-RELEASE
toolchain + Static Linux SDK, but only when Xcode 16.0.0 is the selected version of Xcode.
If I select Xcode 15.4.0, for example, then the build "works" up to the point of this known issue: Missing required module '_FoundationCollections' when building with the Static Linux SDK · Issue #420 · apple/swift-collections · GitHub
Here are the highlights:
- The
swift-6.0-RELEASE
toolchain and corresponding Static Linux SDK are installed (Swift.org - Install Swift). - The
TOOLCHAINS
environment is set to theswift-6.0-RELEASE
toolchain. - The app builds using
--swift-sdk
, e.g.aarch64-swift-linux-musl
.
Regarding the application's Package.swift
manifest:
- A project that pulls in Vapor/ SwiftNIO dependencies generates this error (there is a transitive dependency on swift-collections).
- A project that just pulls in swift-collections generates this error.
- A project that doesn't have any dependencies doesn't generate this error.
- A project that pulls in a dependency without a transitive dependency on swift-collections doesn't generate this error.
Perhaps the known swift-collections issue is also causing this same issue??
And... here's a script that sets up the toolchain and kicks off a build.
#!/bin/zsh
set -e
# Valid values:
# - aarch64-swift-linux-musl
# - x86_64-swift-linux-musl
SWIFT_SDK=$1
SWIFT_TOOLCHAIN_NAME="swift-6.0-RELEASE"
SWIFT_TOOLCHAIN_PATH="/Library/Developer/Toolchains/$SWIFT_TOOLCHAIN_NAME.xctoolchain"
export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw $SWIFT_TOOLCHAIN_PATH/Info.plist)
echo "*****"
echo "***** Swift Toolchain"
echo "***** Name: $SWIFT_TOOLCHAIN_NAME"
echo "***** Path: $SWIFT_TOOLCHAIN_PATH"
echo "***** ID: $TOOLCHAINS"
echo "***** SDK: $SWIFT_SDK"
echo "***** SPM: $(swift package --version)"
echo "***** Xcode: $(xcode-select -p)"
echo "*****"
swift build -c release --swift-sdk $SWIFT_SDK
And here's the script execution showing the error:
$ ./build-swift-custom-toolchain.sh aarch64-swift-linux-musl
*****
***** Swift Toolchain
***** Name: swift-6.0-RELEASE
***** Path: /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain
***** ID: org.swift.600202409101a
***** SDK: aarch64-swift-linux-musl
***** SPM: Swift Package Manager - Swift 6.0.0-dev
***** Xcode: /Applications/Xcode16.0.0.app/Contents/Developer
*****
error: 'vapor': Invalid manifest (compiled with: ["/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/bin/swiftc", "-vfsoverlay", "/var/folders/9z/n8vjtvf54b13j4vw4zm64k880000gp/T/TemporaryDirectory.NophSp/vfs.yaml", "-L", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-lPackageDescription", "-Xlinker", "-rpath", "-Xlinker", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-target", "arm64-apple-macosx13.0", "-I", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/macosx/testing", "-L", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/macosx/testing", "-plugin-path", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing", "-sdk", "/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk", "-F", "/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks", "-I", "/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-L", "/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib", "-swift-version", "5", "-I", "/Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI", "-sdk", "/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk", "-package-description-version", "5.9.0", "/Users/someuser/Developer/Temp/demo/.build/checkouts/vapor/Package@swift-5.9.swift", "-o", "/var/folders/9z/n8vjtvf54b13j4vw4zm64k880000gp/T/TemporaryDirectory.TPf6ZQ/vapor-manifest"])
error: compile command failed due to signal 6 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/someuser/Developer/Temp/demo/.build/checkouts/vapor/Package@swift-5.9.swift -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -I /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -I /Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -I /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI -F /Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -vfsoverlay /var/folders/9z/n8vjtvf54b13j4vw4zm64k880000gp/T/TemporaryDirectory.NophSp/vfs.yaml -swift-version 5 -package-description-version 5.9.0 -empty-abi-descriptor -plugin-path /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -resource-dir /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift -module-name main -plugin-path /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.0 -target-sdk-name macosx15.0 -external-plugin-path /Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode16.0.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -o /var/folders/9z/n8vjtvf54b13j4vw4zm64k880000gp/T/TemporaryDirectory.SSez9H/Package@swift-5.9-1.o
1. Apple Swift version 6.0 (swift-6.0-RELEASE)
2. Compiling with effective version 5.10
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for Darwin)
4. While running pass #2548 SILModuleTransform "MandatorySILLinker".
5. While deserializing SIL function "$s6Darwin14POSIXErrorCodeO8rawValueACSgs5Int32V_tcfC"
6. *** DESERIALIZATION FAILURE ***
*** If any module named here was modified in the SDK, please delete the ***
*** new swiftmodule files from the SDK and keep only swiftinterfaces. ***
module '_errno', builder version '6.0(6.0)/Apple Swift version 6.0 (swift-6.0-RELEASE)', built from swiftinterface, resilient, loaded from '/var/folders/9z/n8vjtvf54b13j4vw4zm64k880000gp/C/clang/ModuleCache/_errno-2S3LNEQ44W3KQ.swiftmodule'
SILFunction type mismatch for '$s6Darwin14POSIXErrorCodeO8rawValueACSgs5Int32V_tcfC': '$@convention(method) (Int32, @thin POSIXErrorCode.Type) -> Optional<POSIXErrorCode>' != '$@convention(method) (Int32, @thin POSIXErrorCode.Type) -> Optional<POSIXErrorCode>'
Switching the Xcode version to Xcode 15.4.0 seems to resolve the error above, but then fails with another known error regarding swift-collections: Missing required module '_FoundationCollections' when building with the Static Linux SDK · Issue #420 · apple/swift-collections · GitHub
$ ./build-swift-custom-toolchain.sh aarch64-swift-linux-musl
*****
***** Swift Toolchain
***** Name: swift-6.0-RELEASE
***** Path: /Library/Developer/Toolchains/swift-6.0-RELEASE.xctoolchain
***** ID: org.swift.600202409101a
***** SDK: aarch64-swift-linux-musl
***** SPM: Swift Package Manager - Swift 6.0.0-dev
***** Xcode: /Applications/Xcode15.4.0.app/Contents/Developer
*****
Building for production...
<unknown>:0: error: missing required module '_FoundationCollections'
<unknown>:0: error: missing required module '_FoundationCollections'
[119/891] Compiling dtls_method.cc
Given the explicit use of the Swift 6 OSS toolchain, I am not sure how/ why the selected Xcode version would come into play, but it appears to have an impact.
Also, I have been successfully using a beta version of the Swift 6 OSS toolchain for a few months (but I also had to set the Xcode version to 15.4.0... was never sure why).
Many thanks in advance.