Skip to content

[build-script] Add support for building static XCTest - #91049

Open
keith wants to merge 2 commits into
mainfrom
ks/add-support-for-building-static-xctest
Open

[build-script] Add support for building static XCTest#91049
keith wants to merge 2 commits into
mainfrom
ks/add-support-for-building-static-xctest

Conversation

@keith

@keith keith commented Jul 29, 2026

Copy link
Copy Markdown
Member

@keith keith changed the title Add support for building static XCTest [build-script] Add support for building static XCTest Jul 29, 2026
@keith

keith commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@swift-ci please test

@keith

keith commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@finagolfin

Copy link
Copy Markdown
Member

Would be great if we could add this for Android too, pinging @swiftlang/android-workgroup if anyone wants to work on it.

@compnerd

Copy link
Copy Markdown
Member

I'm not sure if static linking XCTest is actually supported; CC: @grynspan @stmontgomery @briancroom

@grynspan

Copy link
Copy Markdown
Contributor

It is not supported, no. On non-Apple platforms, it's technically feasible but comes with a bunch of questions we need to answer first; on Apple platforms, it's not really possible because XCTest and Swift Testing are distributed with Xcode as frameworks.

@keith

keith commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

it's technically feasible but comes with a bunch of questions we need to answer first

is there context on this I can read up on?

This is intended only for non-apple platforms (specifically I'm most interested in Linux)

@keith

keith commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@grynspan

Copy link
Copy Markdown
Contributor

it's technically feasible but comes with a bunch of questions we need to answer first

is there context on this I can read up on?

No as I don't think we've even defined all the questions. But in general, if you statically link to Swift Testing or XCTest, you've now got a copy in your executable that could end up shipping to customers. That's not something we want to enable.

This is intended only for non-apple platforms (specifically I'm most interested in Linux)

Changes to Swift Testing or XCTest need to take Apple platforms into account too. While you're not interested in them, we are.

@keith

keith commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

@keith

keith commented Jul 29, 2026

Copy link
Copy Markdown
Member Author

But in general, if you statically link to Swift Testing or XCTest, you've now got a copy in your executable that could end up shipping to customers.

I think this concern is mostly around how we surface this from the build system? For the swiftpm use case users doing swift test --swift-static-stdlib should not ship that binary, and that would cause issues today if they did as well.

Changes to Swift Testing or XCTest need to take Apple platforms into account too. While you're not interested in them, we are.

I didn't mean to imply that I don't care about Apple platforms with this change, just that the intent of this change is to have no effect on toolchains targeting Apple platforms. Please left a comment on the code if you see somewhere where that's not the case! If you think it's worth it we can add some hard fails in the various cmake files if you even attempt to build the static variants targeting macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants