-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Cross-compiling tests with 6.1 Swift SDK results in linking error when host toolchain is 6.0 #8388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sending to the SwiftPM team as the reported error is not produced by Swift Testing. In general, the Swift project does not guarantee any form of ABI stability on Linux, so building with one toolchain and running with another likely wouldn't work for various other reasons, especially if the toolchain used for building is newer than the one used for running. |
Weird that it's failing on the index store. But yes, mixing toolchain versions usually doesn't work, though with more obvious error messages. |
Thanks, I wasn't sure if this was related to how Swift Testing is built or just SwiftPM itself. It only ever happens with Swift Testing, which was indicating to me that perhaps some part of Swift Testing that is in the host installed toolchain (essentially the one you are using to run the |
Well the thing is it should be possible with a Swift SDK, because it includes the same version of Swift as what you are cross-compiling for. So in this Swift SDK it'll have:
And it should be using the |
Description
This is a bit of a meta-issue that I've only seen when cross-compiling with a Swift SDK, but it's very interesting.
So, if I have a Swift SDK generated for a snapshot version of 6.1 (generated using the swift-sdk-generator), and try to compile the tests in a project that use the
Testing
module, I get an error about the object file not being able to be found. For example, I have a project that contains a single test and doesimport Testing
at the top of it:When I compile this with the Swift SDK, when my host toolchain is Swift 6.0.3, I get the following error:
What's interesting is that this doesn't happen if I change my host toolchain to a 6.1 snapshot. For example:
So, it seems to be some kind of mismatch in how the object is compiled when the
Testing
module is involved. However, I am not sure why this happens.Reproduction
swift run swift-sdk-generator make-linux-sdk --swift-version 6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a --swift-branch swift-6.1-branch --host-toolchain --target aarch64-unknown-linux-gnu
swift sdk install /path/to/swift-sdk-generator/Bundles/6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_ubuntu_jammy_aarch64.artifactbundle
--build-tests
:swift build --swift-sdk 6.1-DEVELOPMENT-SNAPSHOT-2025-03-12-a_ubuntu_jammy_aarch64 --build-tests
import Testing
then show the error:<testFile>.swift.o-1WQSNCFA94D5H': No such file or directory
Expected behavior
I would expect that if you cross-compile a project with tests that use Swift Testing, that a difference in the Swift version installed on the host and the one inside of the toolchain would NOT cause an error. If the Swift SDK includes the host toolchain, that should be used to compile for the target instead of the one installed on the host itself.
Environment
Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: x86_64-unknown-linux-gnu
Linux ella-linux 6.8.0-55-generic swiftlang/swift-testing#57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Additional information
Maybe this isn't an issue in the Testing module itself, but in swift-frontend or somewhere else up the chain. If so, please let me know where this belongs.
ALSO: This error does not occur if the project uses
XCTest
for unit tests and does not depend on Swift Testing.The text was updated successfully, but these errors were encountered: