From d95215de5307a7e657293e1f2dc739ff3afe463b Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Tue, 11 Apr 2023 01:59:11 +0100 Subject: [PATCH 1/2] [cxx-interop] Include `Cxx` and `CxxStdlib` modules in no-stdlib builds These modules are shipped with the toolchain, while the stdlib might be built and shipped separately. rdar://107780733 --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6404de27a67cd..538e001f63a05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1265,6 +1265,7 @@ else() if(SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT) add_subdirectory(stdlib/toolchain) + add_subdirectory(stdlib/public/Cxx) endif() if (BUILD_SWIFT_CONCURRENCY_BACK_DEPLOYMENT_LIBRARIES) From 14f32312bf03bd70274b2dc897dab96933db7b71 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Tue, 11 Apr 2023 16:45:39 +0100 Subject: [PATCH 2/2] [cxx-interop] Do not add a dependency on clang to CxxStdlib Cxx & CxxStdlib modules are Swift-only, they do not require invoking clang directly. When building with `SWIFT_INCLUDE_TOOLS=NO`, Clang is not available as a CMake target (see `swift_common_standalone_build_config`). rdar://107780733 --- stdlib/cmake/modules/AddSwiftStdlib.cmake | 3 ++- stdlib/public/Cxx/CMakeLists.txt | 2 +- stdlib/public/Cxx/std/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake index 365b175587abe..9fc316537a211 100644 --- a/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake @@ -1678,6 +1678,7 @@ function(add_swift_target_library name) IS_SDK_OVERLAY IS_STDLIB IS_STDLIB_CORE + IS_SWIFT_ONLY NOSWIFTRT OBJECT_LIBRARY SHARED @@ -1814,7 +1815,7 @@ function(add_swift_target_library name) endif() if(NOT SWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER AND NOT BUILD_STANDALONE AND - NOT SWIFT_PREBUILT_CLANG) + NOT SWIFT_PREBUILT_CLANG AND NOT SWIFTLIB_IS_SWIFT_ONLY) list(APPEND SWIFTLIB_DEPENDS clang) endif() diff --git a/stdlib/public/Cxx/CMakeLists.txt b/stdlib/public/Cxx/CMakeLists.txt index 961a1355c9396..87026aadc4e78 100644 --- a/stdlib/public/Cxx/CMakeLists.txt +++ b/stdlib/public/Cxx/CMakeLists.txt @@ -3,7 +3,7 @@ if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WINDOWS") set(SWIFT_CXX_LIBRARY_KIND SHARED) endif() -add_swift_target_library(swiftCxx ${SWIFT_CXX_LIBRARY_KIND} NO_LINK_NAME IS_STDLIB +add_swift_target_library(swiftCxx ${SWIFT_CXX_LIBRARY_KIND} NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY CxxConvertibleToCollection.swift CxxDictionary.swift CxxPair.swift diff --git a/stdlib/public/Cxx/std/CMakeLists.txt b/stdlib/public/Cxx/std/CMakeLists.txt index bb3215c92d2c0..8fdfb45724993 100644 --- a/stdlib/public/Cxx/std/CMakeLists.txt +++ b/stdlib/public/Cxx/std/CMakeLists.txt @@ -127,7 +127,7 @@ add_dependencies(sdk-overlay libstdcxx-modulemap) # # C++ Standard Library Overlay. # -add_swift_target_library(swiftCxxStdlib STATIC NO_LINK_NAME IS_STDLIB +add_swift_target_library(swiftCxxStdlib STATIC NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY std.swift String.swift