[cxx-interop] Allow compiling with libc++ on Linux

This makes sure that Swift respects `-Xcc -stdlib=libc++` flags.

Clang already has existing logic to discover the system-wide libc++ installation on Linux. We rely on that logic here.

Importing a Swift module that was built with a different C++ stdlib is not supported and emits an error.

The Cxx module can be imported when compiling with any C++ stdlib. The synthesized conformances, e.g. to CxxRandomAccessCollection also work. However, CxxStdlib currently cannot be imported when compiling with libc++, since on Linux it refers to symbols from libstdc++ which have different mangled names in libc++.

rdar://118357548 / https://github.com/swiftlang/swift/issues/69825
This commit is contained in:
Egor Zhdan
2024-07-30 20:01:58 +01:00
parent 536a88971f
commit 059f0f97d1
31 changed files with 348 additions and 28 deletions

View File

@@ -642,6 +642,11 @@ public:
return Core->Bits.HasCxxInteroperability;
}
/// The kind of the C++ stdlib that this module was built with.
CXXStdlibKind getCXXStdlibKind() const {
return static_cast<CXXStdlibKind>(Core->Bits.CXXStdlibKind);
}
/// Whether the module is resilient. ('-enable-library-evolution')
ResilienceStrategy getResilienceStrategy() const {
return ResilienceStrategy(Core->Bits.ResilienceStrategy);