Description
Is it reproducible with SwiftPM command-line tools: swift build
, swift test
, swift package
etc?
- Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands,
swift build
,swift test
,swift package
etc.
Description
I just tried cross-compiling swift-foundation for Android AArch64 using a recent trunk 6.1 Oct. 8 snapshot bundle generated by my daily Android CI. While the command below built fine, I noticed it was building a lot of files, and was surprised to find it was building FoundationICU twice, once for the linux x86_64 host and then again for the Android AArch64 target! This appears to be a SwiftPM bug, as I see no reason to build these swift-foundation dependencies like swift-collections and swift-foundation-icu for the host too:
> ls .build/x86_64-unknown-linux-gnu/debug/
_FoundationCShims-tool.build ModuleCache SwiftParserDiagnostics-tool.build
FoundationEssentialsTests-tool.build Modules-tool SwiftParser-tool.build
FoundationEssentials-tool.build OrderedCollections-tool.build SwiftSyntax509-tool.build
_FoundationICU-tool.build plugin-tools-description.json SwiftSyntax510-tool.build
FoundationInternationalizationTests-tool.build _RopeModule-tool.build SwiftSyntax600-tool.build FoundationInternationalization-tool.build SwiftBasicFormat-tool.build SwiftSyntaxBuilder-tool.build FoundationMacrosTests-tool.build SwiftCompilerPluginMessageHandling-tool.build _SwiftSyntaxCShims-tool.build FoundationMacros-tool SwiftCompilerPlugin-tool.build SwiftSyntaxMacroExpansion-tool.build
FoundationMacros-tool.build SwiftDiagnostics-tool.build SwiftSyntaxMacros-tool.build
FoundationMacros-tool.product swift_foundationPackageDiscoveredTests-tool.build SwiftSyntax-tool.build
index swift_foundationPackageTests-tool.build TestSupport-tool.build InternalCollectionsUtilities-tool.build SwiftOperators-tool.build
I saw this for the first time months ago, so it should be reproducible with Swift 6.0.1 also.
Expected behavior
Only build the Foundation macros for the linux x86_64 host.
Actual behavior
All package dependencies appear to be compiled twice, whether they're used by the macros or not.
Steps to reproduce
- Download my Android SDK bundle from the link above.
- ~/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-ubi9/usr/bin/swift sdk install swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-android-24-0.1.artifactbundle.tar.gz
- cd swift-foundation
- ~/swift-DEVELOPMENT-SNAPSHOT-2024-10-08-a-ubi9/usr/bin/swift build --swift-sdk aarch64-unknown-linux-android24
Swift Package Manager version/commit hash
Definitely the Oct. 8 6.1 snapshot, probably the 6.0 release also
Swift & OS version (output of swift --version ; uname -a
)
Swift 6.1 cross-compiling from Fedora 40 x86_64 to Android AArch64