Skip to content

Commit bedb07a

Browse files
committed
build: Fixes for building Cxx module with/without stdlib.
With the changes introduced in #65055, the Cxx module will build even when not building the stdlib as long as `SWIFT_BUILD_STDLIB_EXTRA_TOOLCHAIN_CONTENT` was set. With the further changes in #65122 the previous flag is not necessary, and only `SWIFT_BUILD_STDLIB_CXX_MODULE` (which defaults to `TRUE`) is necessary. However, `stdlib/public/Cxx` did rely on `StdlibOptions.cmake` to be include before it, or the functions that build the target libraries will find a half configured state. `StdlibOptions.cmake` are included in `stdlib/toolchain`, in `stdlib/` and `StandaloneOverlay.cmake`. Before #65122 it was working just because `stdlib/toolchain` was added just before. The second change adds a dependency on the legacy layouts, which is a dependency only added to the libraries of the stdlib core (IS_STDLIB_CORE flag). Since enabling that flag also enables a bunch other stuff, and I am not sure that Cxx should be classified as "core" anyway, I preferred to add the dependency. This is necessary for builds like the iPhoneOS and iPhoneSimulator, and does not seem to affect macOS.
1 parent 767ec05 commit bedb07a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

stdlib/public/Cxx/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake/modules)
2+
include(StdlibOptions)
3+
14
set(SWIFT_CXX_LIBRARY_KIND STATIC)
25
if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WINDOWS")
36
set(SWIFT_CXX_LIBRARY_KIND SHARED)
@@ -20,6 +23,7 @@ add_swift_target_library(swiftCxx ${SWIFT_CXX_LIBRARY_KIND} NO_LINK_NAME IS_STDL
2023
-Xcc -nostdinc++
2124

2225
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
26+
DEPENDS copy-legacy-layouts
2327
INSTALL_IN_COMPONENT compiler
2428
INSTALL_WITH_SHARED)
2529

0 commit comments

Comments
 (0)