Skip to content

5.10: [interop][SwiftToCxx] Use 'SWIFT_INLINE_PRIVATE_HELPER' for getTypeMetadata helper to avoid emitting a reference to it when 'DEBUG' macro is set #69524

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

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Oct 30, 2023

Fixes #69234

Based on #69522, see last commit only for the diff - 5f4e33d
rdar://117089662

  • Explanation:
    SWIFT_INLINE_THUNK macro used for getTypeMetadata helper in the generated header adds LLVM used attribute to the inline functions when DEBUG is set, to have functions be callable from LLDB's expression evaluation. getTypeMetadata is also emitted for C++ types that are exposed back from Swift to C++, to allow them to be used in Swift generics. However, this can sometimes lead to a linking error because of the used attribute when Swift doesn't actually emit the C++ type metadata, e.g. when such C++ type is not used in a Swift generic type, but is used directly in an exposed Swift API. This change uses SWIFT_INLINE_PRIVATE_HELPER instead for the getTypeMetadata helpers to avoid force linking with the not existing metadata for a C++ type.
  • Scope: C++ interop, generated header generator
  • Risk: Low, this doesn't change underlying behavior, just removes the used LLVM attribute.
  • Testing: Unit tests
  • Original PR: [interop][SwiftToCxx] Use 'SWIFT_INLINE_PRIVATE_HELPER' for getTypeMetadata helper to avoid emitting a reference to it when 'DEBUG' macro is set #69519

@hyp hyp added c++ interop Feature: Interoperability with C++ swift 5.10 labels Oct 30, 2023
@hyp hyp requested a review from a team as a code owner October 30, 2023 22:47
@hyp
Copy link
Contributor Author

hyp commented Oct 30, 2023

@swift-ci please test

…tadata helper to avoid emitting a reference to it when 'DEBUG' macro is set

This is needed as the metadata for C++ types might not be actually emitted and thus we can't always reference it

Fixes swiftlang#69234

rdar://117089662
@hyp hyp force-pushed the eng/5.10/reininlien-getTypeMetadata branch from 5f4e33d to 43a2a84 Compare October 31, 2023 16:22
@hyp
Copy link
Contributor Author

hyp commented Oct 31, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Oct 31, 2023

@swift-ci please test linux platform

@hyp
Copy link
Contributor Author

hyp commented Oct 31, 2023

@swift-ci please test macOS platform

@hyp hyp merged commit 0d2deb5 into swiftlang:release/5.10 Nov 1, 2023
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++ swift 5.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants