Skip to content

Enable Library Evolution in package builds for public library targets #951

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

Merged
merged 3 commits into from
Feb 12, 2025

Conversation

stmontgomery
Copy link
Contributor

This modifies Package.swift to enable Library Evolution for builds of the package.

Motivation:

I recently landed a change (#931) which passed our project-level CI but later failed in Swift CI. The difference ended up being due to the latter building with Library Evolution (LE) enabled, whereas our project-level CI builds via SwiftPM and does not enable LE. The change was reverted (#950) but this revealed a gap in our testing strategy. We should always build these targets with LE enabled.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

Fixes rdar://144655439

@stmontgomery stmontgomery added enhancement New feature or request workaround Workaround for an issue in another component (may need to revert later) build 🧱 Affects the project's build configuration or process labels Feb 12, 2025
@stmontgomery stmontgomery added this to the Swift 6.x milestone Feb 12, 2025
@stmontgomery stmontgomery self-assigned this Feb 12, 2025
@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@@ -199,7 +199,7 @@ public struct Configuration: Sendable {
/// property is pre-configured. Otherwise, the default value of this property
/// records an issue indicating that it has not been configured.
@_spi(Experimental)
public var exitTestHandler: ExitTest.Handler = { _ in
public var exitTestHandler: ExitTest.Handler = { exitTest in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After I enabled Library Evolution, I got a compiler crash when building with a main snapshot toolchain which has asserts enabled:

Begin Error in Function: '$s7Testing13ConfigurationV15exitTestHandleryAA04ExitD9ArtifactsVAA02__fD0VYaYbKcvpfiAfHYaYbKcfU_'
Found outside of lifetime use?!
Value:   %2 = load_borrow %1 : $*__ExitTest              // users: %8, %4, %3
Consuming User:   end_borrow %2 : $__ExitTest                     // id: %4
Non Consuming User:   debug_value %2 : $__ExitTest, let, name "_0", argno 1 // id: %8
Block: bb0

End Error in Function: '$s7Testing13ConfigurationV15exitTestHandleryAA04ExitD9ArtifactsVAA02__fD0VYaYbKcvpfiAfHYaYbKcfU_'
Found ownership error?!
1.  Apple Swift version 6.2-dev (LLVM 5805166b4c9eb06, Swift 57234f8034befac)
2.  Compiling with the current language version
3.  While evaluating request ExecuteSILPipelineRequest(Run pipelines { Non-Diagnostic Mandatory Optimizations, Serialization, Rest of Onone } on SIL for Testing)
4.  While running pass #679 SILFunctionTransform "OwnershipModelEliminator" on SILFunction "@$s7Testing13ConfigurationV15exitTestHandleryAA04ExitD9ArtifactsVAA02__fD0VYaYbKcvpfiAfHYaYbKcfU_".
 for expression at [/Users/stuart/Work/swift-testing/Sources/Testing/Running/Configuration.swift:221:50 - line:223:3] RangeText="{ (_: borrowing ExitTest) throws -> ExitTestArtifacts in
    throw SystemError(description: "Exit test support has not been implemented by the current testing infrastructure.")
  "
5.  Found verification error when verifying before lowering ownership. Please re-run with -sil-verify-all to identify the actual pass that introduced the verification error.
6.  While verifying SIL function "@$s7Testing13ConfigurationV15exitTestHandleryAA04ExitD9ArtifactsVAA02__fD0VYaYbKcvpfiAfHYaYbKcfU_".
 for expression at [/Users/stuart/Work/swift-testing/Sources/Testing/Running/Configuration.swift:221:50 - line:223:3] RangeText="{ (_: borrowing ExitTest) throws -> ExitTestArtifacts in
    throw SystemError(description: "Exit test support has not been implemented by the current testing infrastructure.")
  "

The closure parameter is of type borrowing ExitTest, and as a workaround I found simply giving it a name instead of the wildcard _ resolves the crash. I can file an issue to track that separately tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's bizarre. Okay.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I think this might be the same issue as the one you just had to work around? @jckarter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a different issue than swiftlang/swift#79304

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test

@stmontgomery
Copy link
Contributor Author

@swift-ci please test macOS

@stmontgomery stmontgomery merged commit a4070bc into swiftlang:main Feb 12, 2025
3 checks passed
@stmontgomery stmontgomery deleted the package-library-evolution branch February 12, 2025 23:27
stmontgomery added a commit that referenced this pull request Apr 17, 2025
…ry target (#1082)

This enables Library Evolution (LE) for the `_TestDiscovery` target in
Swift package-based builds. The CMake-based build is already configured
to enable LE for this target, so this is just matching behavior.

(Note that we already enable LE for several other targets which vend
public API as of #951.)

### Checklist:

- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build 🧱 Affects the project's build configuration or process enhancement New feature or request workaround Workaround for an issue in another component (may need to revert later)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants