Skip to content

Commit 539fc69

Browse files
authored
build: Fixes for building Cxx module with/without stdlib. (#65172)
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 159385e commit 539fc69

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
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)
47
endif()
58

9+
set(SWIFT_CXX_DEPS symlink_clang_headers)
10+
if(SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT)
11+
list(APPEND SWIFT_CXX_DEPS copy-legacy-layouts)
12+
endif()
13+
614
add_swift_target_library(swiftCxx ${SWIFT_CXX_LIBRARY_KIND} NO_LINK_NAME IS_STDLIB IS_SWIFT_ONLY
715
CxxConvertibleToCollection.swift
816
CxxDictionary.swift
@@ -20,6 +28,7 @@ add_swift_target_library(swiftCxx ${SWIFT_CXX_LIBRARY_KIND} NO_LINK_NAME IS_STDL
2028
-Xcc -nostdinc++
2129

2230
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
31+
DEPENDS ${SWIFT_CXX_DEPS}
2332
INSTALL_IN_COMPONENT compiler
2433
INSTALL_WITH_SHARED)
2534

0 commit comments

Comments
 (0)