Skip to content

SwiftPM selects wrong architecture from multi-arch Swift SDK when using --swift-sdk and --triple #9220

@krzyzanowskim

Description

@krzyzanowskim

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

When building with a multi-architecture Swift SDK using both --swift-sdk and --triple, SwiftPM nondeterministically selects the wrong architecture variant from the SDK bundle, ignoring the target triple specified via --triple.

The SDK bundle contains both x86_64 and aarch64 variants, and even though --triple aarch64-swift-linux-musl is specified, SwiftPM sometimes selects the x86_64 variant instead, causing build failures.

Expected behavior

SwiftPM should select the SDK variant matching the --triple argument (aarch64) from the multi-arch SDK bundle.

Actual behavior

SwiftPM nondeterministically selects between x86_64 and aarch64 variants

Steps to reproduce

  1. Install a multi-architecture Swift SDK (SDK contains both x86_64-swift-linux-musl and aarch64-swift-linux-musl)
    $ swift sdk list
    # Output: swift-6.2-RELEASE_static-linux-0.0.1
  2. Create a minimal test package:
    $ mkdir -p /tmp/swiftpm-bug-repro && cd /tmp/swiftpm-bug-repro
    $ swift package init --type executable --name TestApp
  3. Build for aarch64 Linux:
    $ swift build --swift-sdk swift-6.2-RELEASE_static-linux-0.0.1 --triple aarch64-swift-linux-musl -Xswiftc -static-executable
  4. Observe the warning and error:
    warning: multiple Swift SDKs match ID swift-6.2-RELEASE_static-linux-0.0.1 and host triple arm64-apple-macosx26.0
    error: could not find module '_Concurrency' for target 'aarch64-swift-linux-musl';
    found: x86_64-swift-linux-musl, at: .../x86_64/usr/lib/swift_static/linux-static/_Concurrency.swiftmodule
  5. Run multiple times to observe nondeterministic behavior (sometimes succeeds, sometimes fails with wrong architecture)

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

Swift version: Apple Swift version 6.2 (swift-6.2-RELEASE)
Platform: macOS 26.0.1 (arm64-apple-macosx26.0)
Swift SDK: swift-6.2-RELEASE_static-linux-0.0.1 (multi-arch: x86_64 and aarch64)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions