mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -198,6 +198,11 @@ static bool readOptionsBlock(llvm::BitstreamCursor &cursor,
|
||||
case options_block::HAS_CXX_INTEROPERABILITY_ENABLED:
|
||||
extendedInfo.setHasCxxInteroperability(true);
|
||||
break;
|
||||
case options_block::CXX_STDLIB_KIND:
|
||||
unsigned rawKind;
|
||||
options_block::CXXStdlibKindLayout::readRecord(scratch, rawKind);
|
||||
extendedInfo.setCXXStdlibKind(static_cast<CXXStdlibKind>(rawKind));
|
||||
break;
|
||||
case options_block::ALLOW_NON_RESILIENT_ACCESS:
|
||||
extendedInfo.setAllowNonResilientAccess(true);
|
||||
break;
|
||||
@@ -1461,6 +1466,7 @@ ModuleFileSharedCore::ModuleFileSharedCore(
|
||||
extInfo.isAllowModuleWithCompilerErrorsEnabled();
|
||||
Bits.IsConcurrencyChecked = extInfo.isConcurrencyChecked();
|
||||
Bits.HasCxxInteroperability = extInfo.hasCxxInteroperability();
|
||||
Bits.CXXStdlibKind = static_cast<uint8_t>(extInfo.getCXXStdlibKind());
|
||||
Bits.AllowNonResilientAccess = extInfo.allowNonResilientAccess();
|
||||
Bits.SerializePackageEnabled = extInfo.serializePackageEnabled();
|
||||
MiscVersion = info.miscVersion;
|
||||
|
||||
Reference in New Issue
Block a user