Skip to content

Commit aab7a5f

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 changes adds dependencies on the legacy layouts and the clang headers. The legacy layouts are 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. The clang headers are another dependency of the swiftCore, which otherwise causes problems to not find the compiler headers when building Cxx. This is necessary for builds that use a previously built compiler to compile the stdlib.
1 parent 767ec05 commit aab7a5f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,7 @@ else()
12821282

12831283
# Some tools (e.g. swift-reflection-dump) rely on a host swiftRemoteInspection,
12841284
# so ensure we build that when building tools.
1285-
if(SWIFT_INCLUDE_TOOLS)
1285+
if(SWIFT_INCLUDE_TOOLS OR SWIFT_BUILD_STDLIB_CXX_MODULE)
12861286
add_subdirectory(stdlib/public/SwiftShims/swift/shims)
12871287
endif()
12881288

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 symlink_clang_headers
2327
INSTALL_IN_COMPONENT compiler
2428
INSTALL_WITH_SHARED)
2529

0 commit comments

Comments
 (0)