Skip to content

Commit 61c1ef4

Browse files
committed
macOS smoketest: enable Distributed and Synchronization in runtimes
To make this work: * expose SwiftCMakeConfig.h from the Core build system, to support scenarios in which the downstream Distributed build is leveraging the config files generated by CMake itself. * adjust how SwiftShims is defined in `FindSwiftCore.cmake`, so that the shims are found from C++ and that we don't get redefinition errors when multiple module maps are in the search paths. Fixes #83449 Addresses rdar://149241603, rdar://157165530
1 parent e9f19fc commit 61c1ef4

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
17111711
# To ensure incremental builds work as expected
17121712
BUILD_ALWAYS 1
17131713
CMAKE_ARGS
1714-
-DSwift_ENABLE_RUNTIMES=StringProcessing
1714+
-DSwift_ENABLE_RUNTIMES=StringProcessing|Synchronization|Distributed
17151715
-DBUILD_SHARED_LIBS=YES
17161716
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
17171717
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}

Runtimes/Core/runtime/CMakeLists.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ configure_file("CMakeConfig.h.in"
22
"${PROJECT_BINARY_DIR}/include/swift/Runtime/CMakeConfig.h"
33
ESCAPE_QUOTES @ONLY)
44

5+
install(FILES
6+
"${PROJECT_BINARY_DIR}/include/swift/Runtime/CMakeConfig.h"
7+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/swift/Runtime"
8+
COMPONENT SwiftCore_development)
9+
10+
add_library(swiftRuntimeCMakeConfig INTERFACE)
11+
target_include_directories(swiftRuntimeCMakeConfig INTERFACE
12+
$<$<COMPILE_LANGUAGE:C,CXX>:$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>>
13+
$<$<COMPILE_LANGUAGE:Swift>:$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>>)
14+
15+
install(TARGETS swiftRuntimeCMakeConfig
16+
EXPORT SwiftCoreTargets
17+
COMPONENT SwiftCore_development)
18+
519
add_library(swiftRuntime OBJECT
620
"${PROJECT_SOURCE_DIR}/CompatibilityOverride/CompatibilityOverride.cpp"
721
AnyHashableSupport.cpp
@@ -94,14 +108,14 @@ target_compile_definitions(swiftRuntime
94108
$<$<BOOL:${SwiftCore_ENABLE_OS_TRACE_LAZY_INIT}>:-DSWIFT_USE_OS_TRACE_LAZY_INIT>)
95109

96110
target_include_directories(swiftRuntime PRIVATE
97-
"${PROJECT_BINARY_DIR}/include"
98111
"${CMAKE_CURRENT_SOURCE_DIR}")
99112

100113
target_link_libraries(swiftRuntime PRIVATE
101114
$<$<PLATFORM_ID:Windows>:User32>
102115
$<$<PLATFORM_ID:Windows>:ShLwApi>
103116
swiftShims
104-
swiftDemangling)
117+
swiftDemangling
118+
swiftRuntimeCMakeConfig)
105119

106120
# FIXME: Refactor so that we're not pulling sources from the compiler files
107121
target_sources(swiftRuntime PRIVATE

Runtimes/Supplemental/Distributed/CMakeLists.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ endif()
131131
target_include_directories(swiftDistributed PRIVATE
132132
# FIXME: Use of `swift/Runtime/...`, `swift/ABI/...`, and `swift/Demangling/...`
133133
"${${PROJECT_NAME}_SWIFTC_SOURCE_DIR}/include"
134-
# For `swift/runtime/CMakeConfig.h`, which should be generated
135-
# by the Core build system.
136-
"${${PROJECT_NAME}_PATH_TO_SWIFT_RUNTIME_HEADERS}"
137134
# For llvm/support headers
138135
"${PROJECT_SOURCE_DIR}/include")
139136

@@ -143,8 +140,22 @@ target_link_libraries(swiftDistributed PRIVATE
143140
swift_Concurrency
144141
swift_Builtin_float
145142
$<$<PLATFORM_ID:Android>:swiftAndroid>
146-
$<$<PLATFORM_ID:Windows>:swiftWinSDK>)
147-
# swiftDarwin/Libc/Platform
143+
$<$<PLATFORM_ID:Windows>:swiftWinSDK>
144+
$<$<PLATFORM_ID:Windows>:swiftDarwin>)
145+
146+
if(TARGET swiftRuntimeCMakeConfig)
147+
target_link_libraries(swiftDistributed PRIVATE
148+
swiftRuntimeCMakeConfig)
149+
else()
150+
if(DEFINED ${PROJECT_NAME}_PATH_TO_SWIFT_RUNTIME_HEADERS)
151+
target_include_directories(swiftDistributed PRIVATE
152+
# For `swift/runtime/CMakeConfig.h`, which should be generated
153+
# by the Core build system.
154+
"${${PROJECT_NAME}_PATH_TO_SWIFT_RUNTIME_HEADERS}")
155+
else()
156+
message(FATAL_ERROR "To be able to find the CMakeConfig.h header, please ensure that either ${PROJECT_NAME}_PATH_TO_SWIFT_RUNTIME_HEADERS is set, or that swiftRuntimeCMakeConfig target is present ")
157+
endif()
158+
endif()
148159

149160
install(TARGETS swiftDistributed
150161
EXPORT SwiftDistributedTargets

Runtimes/Supplemental/cmake/modules/FindSwiftCore.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ find_path(SwiftShims_INCLUDE_DIR "shims/module.modulemap" HINTS
288288
${SwiftShims_INCLUDE_DIR_HINTS})
289289
add_library(swiftShims INTERFACE IMPORTED GLOBAL)
290290
set_target_properties(swiftShims PROPERTIES
291-
INTERFACE_INCLUDE_DIRECTORIES "${SwiftShims_INCLUDE_DIR}/shims")
291+
INTERFACE_INCLUDE_DIRECTORIES "${SwiftShims_INCLUDE_DIR}/..;${SwiftShims_INCLUDE_DIR}/shims")
292+
target_compile_options(swiftShims INTERFACE
293+
"$<$<AND:$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xcc -DSWIFT_STATIC_STDLIB>"
294+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -fmodule-map-file=\"${SwiftShims_INCLUDE_DIR}/shims/module.modulemap\">")
292295

293296
find_package_handle_standard_args(SwiftCore DEFAULT_MSG
294297
SwiftCore_LIBRARY SwiftCore_INCLUDE_DIR

0 commit comments

Comments
 (0)