Skip to content

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

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 1 commit into from
Jun 20, 2025

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jun 18, 2025

  • Explanation: 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.

  • Scope: This change adds @_alwaysEmitIntoClient to generic usages of Span in the Cxx module to prevent the type metadata accessor from being emitted into libswiftCxx.a.
  • Issues: rdar://152192080
  • Original PRs: [cxx-interop] Make usages of Swift Span @_alwaysEmitIntoClient in the overlay #82309
  • Risk: Low, only makes a few methods @_alwaysEmitIntoClient.
  • Testing: Manually tested that the change fixes the build of the project.

…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 18, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review June 18, 2025 16:39
@egorzhdan egorzhdan requested a review from a team as a code owner June 18, 2025 16:39
@egorzhdan egorzhdan enabled auto-merge June 19, 2025 12:03
@egorzhdan egorzhdan merged commit 7158f82 into release/6.2 Jun 20, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.2-span-shared-cache branch June 20, 2025 12:28
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.

2 participants