Skip to content

[cxx-interop] Make usages of Swift Span @_alwaysEmitIntoClient in the overlay #82309

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

egorzhdan
Copy link
Contributor

This fixes a regression where projects that use the C++ stdlib overlay stop building because of a linker error:

ld: Shared cache eligible dylib cannot link to ineligible dylib '@rpath/libswiftCompatibilitySpan.dylib'.

Usages of Span<T> would generally cause a type metadata accessor to be emitted for Swift.Span. This becomes a problem with backdeployment, since Span is partially defined in a compatibility binary.

This change adds @_alwaysEmitIntoClient to generic usages of Span to prevent the type metadata accessor from being emitted into libswiftCxx.a.

rdar://152192080

…he overlay

This fixes a regression where projects that use the C++ stdlib overlay stop building because of a linker error:
```
ld: Shared cache eligible dylib cannot link to ineligible dylib '@rpath/libswiftCompatibilitySpan.dylib'.
```

Usages of `Span<T>` would generally cause a type metadata accessor to be emitted for `Swift.Span`. This becomes a problem with backdeployment, since Span is partially defined in a compatibility binary.

This change adds `@_alwaysEmitIntoClient` to generic usages of `Span` to prevent the type metadata accessor from being emitted into `libswiftCxx.a`.

rdar://152192080
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 17, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

LGTM! Hopefully it fixes the problem we're seeing (and if not, it's a good change anyway)

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants