Skip to content

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Sep 9, 2025

Library evolution only makes sense on platforms where ABI stability is available. Introduce a new option which defaults to TRUE only on Darwin, the only platform currently providing ABI stability.

@grynspan grynspan added windows 🪟 Windows support linux 🐧 Linux support (all distros) build 🧱 Affects the project's build configuration or process android 🤖 Android support freebsd 😈 FreeBSD support openbsd 🐡 OpenBSD support labels Sep 9, 2025
@grynspan grynspan added this to the Swift 6.x (main) milestone Sep 9, 2025
@@ -18,6 +18,7 @@ add_library(_Testing_Foundation
ReexportTesting.swift)

target_link_libraries(_Testing_Foundation PUBLIC
_TestingInternals
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Foundation overlay shouldn't need to link to this module.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that it did - there was a missing module error otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overlay doesn't import it and it's a static library, so if it's complaining, that probably aligns with what @stmontgomery noted in his comment.

@@ -35,6 +36,7 @@ endif()
# interface, because Foundation does not have Library Evolution enabled for all
# platforms.
target_compile_options(_Testing_Foundation PRIVATE
-emit-module-interface -emit-module-interface-path $<TARGET_PROPERTY:_Testing_Foundation,Swift_MODULE_DIRECTORY>/_Testing_Foundation.swiftinterface)
-emit-module-interface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a stylistic change, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after the indentation for the conditional, yes.

-enable-library-evolution
-emit-module-interface -emit-module-interface-path $<TARGET_PROPERTY:Testing,Swift_MODULE_DIRECTORY>/Testing.swiftinterface)

if(SwiftTesting_ENABLE_LIBRARY_EVOLUTION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this module needs a .swiftinterface even without library evolution, no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The swift interface is not generated without library evolution AFAIK. @etcwilde?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift interfaces are invalid without library evolution. Swift can't describe struct layouts and the interface doesn't include all properties resulting in ABI issues without library evolution.

Copy link
Contributor

@stmontgomery stmontgomery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand Library Evolution (LE) is only supported on Apple platforms currently, but (based on past conversations with knowledgeable Swift compiler engineers) it is not considered problematic to use LE on other platforms as long as you ensure the code is only used with Swift runtime libraries aligned with the toolchain which built the code. Testing libraries and test-only modules have a notable difference from ordinary application and library targets: they're never intended for distribution to end users, and should only validate locally-built code. Because they're not distributed, historically we have enforced that users may only run tests using the same toolchain and runtime libraries which were used to build them.

We intentionally enable Library Evolution on all platforms for a couple reasons. For one thing, we make extensive use of @_spi for new features, and including binary .swiftmodules in the toolchain makes those SPIs freely available on the relevant platforms. Also, when LE is not enabled I believe all module dependencies must be visible to clients, which means things like our _TestingInternals module must be exposed.

For these reasons, I'm pretty hesitant to proceed with this since we've intentionally had things this way. I'd love to understand your motivation for this PR more though, to see what other options are available.

@compnerd
Copy link
Member Author

compnerd commented Sep 9, 2025

I understand Library Evolution (LE) is only supported on Apple platforms currently, but (based on past conversations with knowledgeable Swift compiler engineers) it is not considered problematic to use LE on other platforms as long as you ensure the code is only used with Swift runtime libraries aligned with the toolchain which built the code. Testing libraries and test-only modules have a notable difference from ordinary application and library targets: they're never intended for distribution to end users, and should only validate locally-built code. Because they're not distributed, historically we have enforced that users may only run tests using the same toolchain and runtime libraries which were used to build them.

We intentionally enable Library Evolution on all platforms for a couple reasons. For one thing, we make extensive use of @_spi for new features, and including binary .swiftmodules in the toolchain makes those SPIs freely available on the relevant platforms. Also, when LE is not enabled I believe all module dependencies must be visible to clients, which means things like our _TestingInternals module must be exposed.

For these reasons, I'm pretty hesitant to proceed with this since we've intentionally had things this way. I'd love to understand your motivation for this PR more though, to see what other options are available.

The appeal to authority is not helpful, but please do pull the engineers into the conversation here so that we can make an appropriate technical decision.

Well, the issue is that with library evolution, swift-testing cannot be built on non-Apple platforms. This is only appearing as an issue now because the new runtimes build does not build the standard library runtime with library evolution. @etcwilde rightly pointed out that the library evolution without ABI stability doesn't offer any value. When the standard library is not built with library evolution, the client has no option - it cannot be built with library evolution.

If Apple is able to lift the restriction and support the swift interface without library evolution, we should absolutely consider this.

@grynspan
Copy link
Contributor

Well, the issue is that with library evolution, swift-testing cannot be built on non-Apple platforms.

We've certainly been building successfully in nightlies. What's changed?

Library evolution only makes sense on platforms where ABI stability is
available. Introduce a new option which defaults to `TRUE` only on
Darwin, the only platform currently providing ABI stability.
@grynspan
Copy link
Contributor

We had a discussion off GitHub about this PR and think we need to involve some folks from the core team and/or swift-build effort to help us out.

@stmontgomery
Copy link
Contributor

Offline, we discussed this and believe it would be better resolved by a compiler change for which I filed swiftlang/swift#84241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android 🤖 Android support build 🧱 Affects the project's build configuration or process freebsd 😈 FreeBSD support linux 🐧 Linux support (all distros) openbsd 🐡 OpenBSD support windows 🪟 Windows support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants