Files
swift-mirror/stdlib/public/Cxx/CMakeLists.txt
Egor Zhdan 10ab242b64 [cxx-interop] Do not install binary .swiftmodule files for the overlays
This fixes a deserialization failure in the compiler that occurred while loading the CxxStdlib overlay module:
```
Cross-reference to module 'Swift'
... Optional
... some
... with type <τ_0_0 where τ_0_0 : ~Copyable, τ_0_0 : ~Escapable> (Optional<τ_0_0>.Type) -> (τ_0_0) -> Optional<τ_0_0>
```

This was happening because the overlays were built against a different version of the Swift stdlib than is being used. The compiler is able to rebuild the Cxx and CxxStdlib modules from their textual interfaces. Let's use that feature unconditionally in production toolchains to avoid this kind of binary incompatibilities.

rdar://150416863
(cherry picked from commit 16b280862a)
2025-05-12 19:30:15 +01:00

48 lines
1.8 KiB
CMake

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake/modules)
include(StdlibOptions)
set(SWIFT_CXX_DEPS symlink_clang_headers)
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
list(APPEND SWIFT_CXX_DEPS copy-legacy-layouts)
endif()
add_swift_target_library(swiftCxx STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY
CxxConvertibleToBool.swift
CxxConvertibleToCollection.swift
CxxDictionary.swift
CxxPair.swift
CxxOptional.swift
CxxSet.swift
CxxRandomAccessCollection.swift
CxxSequence.swift
CxxVector.swift
CxxSpan.swift
UnsafeCxxIterators.swift
SWIFT_COMPILE_FLAGS ${SWIFT_RUNTIME_SWIFT_COMPILE_FLAGS} ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
-cxx-interoperability-mode=default
-enable-experimental-feature Span
-enable-experimental-feature BuiltinModule
-enable-experimental-feature AllowUnsafeAttribute
-strict-memory-safety
# This module should not pull in the C++ standard library, so we disable it explicitly.
# For functionality that depends on the C++ stdlib, use C++ stdlib overlay (`swiftstd` module).
-Xcc -nostdinc++
DEPLOYMENT_VERSION_OSX ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_OSX}
DEPLOYMENT_VERSION_IOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_IOS}
DEPLOYMENT_VERSION_TVOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_TVOS}
DEPLOYMENT_VERSION_WATCHOS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_WATCHOS}
DEPLOYMENT_VERSION_XROS ${COMPATIBILITY_MINIMUM_DEPLOYMENT_VERSION_XROS}
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
DEPENDS ${SWIFT_CXX_DEPS}
MACCATALYST_BUILD_FLAVOR zippered
INSTALL_IN_COMPONENT compiler
INSTALL_BINARY_SWIFTMODULE NON_DARWIN_ONLY
INSTALL_WITH_SHARED)
add_subdirectory(libstdcxx)
add_subdirectory(std)
add_subdirectory(cxxshim)