Skip to content

swift sdk configure settings are not used for cross-compilation #8958

@marcprux

Description

@marcprux

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

The configured values specified as part of swift sdk configure are not being used when building with swift build --swift-sdk …. For example, if I install the static Linux SDK and then configure it with invalid values (non-existent folders) for the various options, and then try to build a project, the build should fail. Instead, it appears the values from the SDK's swift-sdk.json are used regardless of the attempted configuration overrides.

$ swift sdk list
swift-6.1.2-RELEASE_static-linux-0.0.1

$ swift sdk configure swift-6.1.2-RELEASE_static-linux-0.0.1 aarch64-swift-linux-musl --sdk-root-path /bogus --swift-resources-path /bogus --swift-static-resources-path /bogus --include-search-path /bogus --library-search-path /bogus --toolset-path /bogus
info: These properties of Swift SDK `swift-6.1.2-RELEASE_static-linux-0.0.1` for target triple `aarch64-swift-linux-musl` were successfully updated: sdkRootPath, swiftResourcesPath, swiftStaticResourcesPath, includeSearchPath, librarySearchPath, toolsetPath.

$ swift sdk configure swift-6.1.2-RELEASE_static-linux-0.0.1 aarch64-swift-linux-musl --show-configuration
sdkRootPath: /bogus
swiftResourcesPath: /bogus
swiftStaticResourcesPath: /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64/usr/lib/swift_static
includeSearchPaths: ["/bogus"]
librarySearchPaths: ["/bogus"]
toolsetPaths: ["/bogus"]

$ swift build --swift-sdk aarch64-swift-linux-musl -v
warning: 'testing-sample': /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/Package.swift -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk -I /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -I /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -vfsoverlay /var/folders/zl/wkdjv4s1271fbm6w0plzknkh0000gn/T/com.apple.shortcuts.mac-helper/TemporaryDirectory.hTh7HN/vfs.yaml -swift-version 6 -package-description-version 6.1.0 -empty-abi-descriptor -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -resource-dir /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift -module-name main -in-process-plugin-server-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -target-sdk-version 15.5 -target-sdk-name macosx15.5 -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -external-plugin-path '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server' -o /var/folders/zl/wkdjv4s1271fbm6w0plzknkh0000gn/T/com.apple.shortcuts.mac-helper/TemporaryDirectory.s92t4n/Package-1.o
/Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/clang /var/folders/zl/wkdjv4s1271fbm6w0plzknkh0000gn/T/com.apple.shortcuts.mac-helper/TemporaryDirectory.s92t4n/Package-1.o -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks --sysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk --target=arm64-apple-macosx13.0 /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/libswiftCompatibilityPacks.a -L /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.5.sdk/usr/lib/swift -L /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI -L /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -lPackageDescription -Xlinker -rpath -Xlinker /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/pm/ManifestAPI -o /var/folders/zl/wkdjv4s1271fbm6w0plzknkh0000gn/T/com.apple.shortcuts.mac-helper/TemporaryDirectory.vqMGon/testing-sample-manifest
Apple Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: arm64-apple-macosx13.0
Planning build
Building for debugging...
Write auxiliary file /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/swift-version-D4C7CC622E9D0AC.txt
/Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/swiftc -module-name LibraryDemo -emit-dependencies -emit-module -emit-module-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules/LibraryDemo.swiftmodule -output-file-map /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/LibraryDemo.build/output-file-map.json -parse-as-library -incremental -c @/opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/LibraryDemo.build/sources -I /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules -target aarch64-swift-linux-musl -v -enable-batch-mode -index-store-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/index/store -Onone -enable-testing -j10 -DSWIFT_PACKAGE -DDEBUG -module-cache-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/ModuleCache -resource-dir /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64/usr/lib/swift_static -parseable-output -parse-as-library -color-diagnostics -swift-version 6 -static-executable -static-stdlib -tools-directory /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/swift.xctoolchain/usr/bin -sdk /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64 -g -Xcc --sysroot -Xcc /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64 -Xcc -g -package-name testing_sample -Xcc -fno-omit-frame-pointer
Apple Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: aarch64-swift-linux-musl
/Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/Sources/LibraryDemo/LibraryDemo.swift -target aarch64-swift-linux-musl -Xllvm -aarch64-use-tbi -disable-objc-interop -sdk /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64 -I /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -empty-abi-descriptor -resource-dir /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64/usr/lib/swift_static -use-static-resource-dir -enable-anonymous-context-mangled-names -file-compilation-dir /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample -Xcc --sysroot -Xcc /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64 -Xcc -g -Xcc -fno-omit-frame-pointer -module-name LibraryDemo -package-name testing_sample -in-process-plugin-server-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -emit-module-doc-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules/LibraryDemo.swiftdoc -emit-module-source-info-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules/LibraryDemo.swiftsourceinfo -emit-dependencies-path /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/LibraryDemo.build/LibraryDemo.emit-module.d -parse-as-library -o /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules/LibraryDemo.swiftmodule
/Users/marc/Library/Developer/Toolchains/swift-6.1.2-RELEASE.xctoolchain/usr/bin/swift-frontend -modulewrap /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules/LibraryDemo.swiftmodule -target aarch64-swift-linux-musl -o /opt/src/github/swift-android-sdk/swift-android-samples/testing-sample/.build/aarch64-swift-linux-musl/debug/Modules/LibraryDemo.o
Build complete! (0.37s)

If the configured values were being used, the build command would not include the default value from swift-sdk.json (-Xcc --sysroot -Xcc /Users/marc/Library/org.swift.swiftpm/swift-sdks/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle/swift-6.1.2-RELEASE_static-linux-0.0.1/swift-linux-musl/musl-1.2.5.sdk/aarch64), but instead would reference /bogus, and the build command would fail.

This is irrespective of the recent fixes around swift sdk configure in #8687 and #8856.

Expected behavior

The values specified as part of swift sdk configure should be used when compiling with a Swift SDK. Specifying invalid values (e.g., paths that do not exist) for parameters like sdk-root-path should cause compilation to fail.

Actual behavior

The values for the various SDK properties seem to be ignored when

Steps to reproduce

  1. swift sdk install https://download.swift.org/swift-6.1.2-release/static-sdk/swift-6.1.2-RELEASE/swift-6.1.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum df0b40b9b582598e7e3d70c82ab503fd6fbfdff71fd17e7f1ab37115a0665b3b
  2. swift sdk configure swift-6.1.2-RELEASE_static-linux-0.0.1 aarch64-swift-linux-musl --sdk-root-path /bogus --swift-resources-path /bogus --swift-static-resources-path /bogus --include-search-path /bogus --library-search-path /bogus --toolset-path /bogus
  3. swift sdk configure swift-6.1.2-RELEASE_static-linux-0.0.1 aarch64-swift-linux-musl --show-configuration
  4. mkdir SampleLibrary
  5. cd SampleLibrary
  6. swift package init
  7. swift build --swift-sdk aarch64-swift-linux-musl
  8. Build should fail due to invalid paths being used, but it succeeds.

Swift Package Manager version/commit hash

swift-6.1.2-RELEASE

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

Apple Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: arm64-apple-macosx15.0
Darwin zap.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:49 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6000 arm64

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