Skip to content

Build CompatibilitySpan shim #79703

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 6 commits into from
Mar 25, 2025

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Feb 28, 2025

This PR allows the implementation of Span and RawSpan to be built as a standalone dynamic library, exporting the same symbol names as the standard library implementation of those types.

The actual libswiftCompatibilitySpan.dylib goes in <build dir>/lib/swift-6.2/$OS. We also create a symbolic link in <build dir>/lib/swift/$OS, from libswiftCompatibilitySpan.dylib to libswiftCore.dylib.

The missing piece is generating the correct $ld$previous symbols in libswiftCore.dylib. I'm going to do that in a separate pull request.

@slavapestov slavapestov force-pushed the span-backward-deployment branch 3 times, most recently from 4d8b499 to 5397c61 Compare March 5, 2025 22:46
@slavapestov slavapestov changed the title stdlib: Add a dummy Compatibility62 shim Build Compatibility62 shim Mar 14, 2025
@slavapestov slavapestov force-pushed the span-backward-deployment branch 3 times, most recently from ee2d77a to 0a6f54f Compare March 21, 2025 05:01
@slavapestov slavapestov marked this pull request as ready for review March 21, 2025 05:01
@slavapestov slavapestov force-pushed the span-backward-deployment branch 2 times, most recently from 8a3d88b to e6e4e51 Compare March 21, 2025 16:43
# stdlib/toolchain/Compatibility62. When running a binary with an old
# standard library, this dynamic library must be present at run time.
#
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
Copy link
Member

Choose a reason for hiding this comment

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

You should sync up with @etcwilde about also building this with the newer build system

Copy link
Member

Choose a reason for hiding this comment

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

The compatibility libraries will be split out in the new build since they need to be built exactly as they were to match the original version. We don't want changes to the Swift or C++ version to impact them.

@slavapestov
Copy link
Contributor Author

I'm going to try an experiment suggested by @DougGregor before I land this where we replace the symlink with a dummy dylib, but let's see what happens with a CI toolchain build in the meantime...

Comment on lines 13 to 14
// A handful of standard library stubs to allow Span.swift and RawSpan.swift
// to be compiled as part of the compatibility shim.
Copy link
Member

Choose a reason for hiding this comment

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

That's clever. So long we're not creating any public symbols here, this approach seems good. We could possibly pare this down further by breaking up the Span.swift/RawSpan.swift files into the ABI-affecting parts (that need to be included here) and the non-ABI-affecting parts.... but I think that's potentially easy to mess up.

Copy link
Contributor Author

@slavapestov slavapestov Mar 21, 2025

Choose a reason for hiding this comment

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

I was thinking as long as the implementation/API of Span is still in flux, it's best to build the actual source files from the stdlib. But eventually we might want to fork the shim's version of the code like you say because the @_aeic declarations don't need to be included at all.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. We can fork after the Swift 6.2 version is finalized, so we don't accidentally change back-deployed version afterward.

This dynamic library contains a copy of the standard library's
exported entry points for the Span and RawSpan types. This will
allow backward deployment of code that uses those new types.
… linker directive purposes

The module name changes the symbol mangling, and also causes
TBDGen to emit linker directives. To separate out these two
behaviors, introduce a terrible hack. If the module name
contains a semicolon (`;`), the part before the semicolon
is the module name for mangling, and the part after the
semicolon is the module name for linker directives.

If there is no semicolon, both module names are identical,
and the behavior is the same as before.
It doesn't change anything about how we interpret the interface.
@slavapestov slavapestov force-pushed the span-backward-deployment branch from e6e4e51 to b0627e2 Compare March 24, 2025 21:57
@slavapestov
Copy link
Contributor Author

@swift-ci Please test

@slavapestov slavapestov changed the title Build Compatibility62 shim Build CompatibilitySpan shim Mar 24, 2025
@slavapestov slavapestov merged commit 6463dcb into swiftlang:main Mar 25, 2025
5 checks passed
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.

3 participants