Swift-to-C++: getTypeMetadata
inline helpers that refer to C++ type metadata are annotated as used
for debug compilations, causing linker errors
#69234
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
c++ interop
Feature: Interoperability with C++
compiler
The Swift compiler itself
linker error
swift to c++
Feature → c++ interop: swift to c++
swift 5.10
swift 6.0
as reported on https://forums.swift.org/t/undeclared-use-of-identifier-in-generated-module-swift-file/67894.
It shows up as a linker error like this:
This is caused by how the C++
getTypeMetadata
inline function is annotated in the generated header. It uses theSWIFT_INLINE_THUNK
annotation which in debug mode in Xcode (whenDEBUG
is defined as a preprocessor macro/Swift build condition) is forced to be emitted into the object file, even when it's not used. This is wrong, as it's not supposed to be linked in forcefully and should only be needed when it's actually used.Such functions should be annotated with
SWIFT_INLINE_PRIVATE_HELPER
instead.The text was updated successfully, but these errors were encountered: