Skip to content

Commit 48fd452

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 48fd452

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
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/core/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,9 @@ target_link_libraries(swiftCore
336336
swiftThreading
337337
$<$<NOT:$<PLATFORM_ID:Darwin>>:swiftrt$<$<PLATFORM_ID:Windows>:T>>
338338
PUBLIC
339-
swiftShims)
339+
swiftShims
340+
INTERFACE
341+
swiftRuntimeCMakeConfig)
340342

341343
string(TOLOWER "${SwiftCore_OBJECT_FORMAT}" SwiftCore_OBJECT_FORMAT_lc)
342344
if("${SwiftCore_OBJECT_FORMAT_lc}" STREQUAL "elf")

Runtimes/Core/runtime/CMakeLists.txt

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

5+
add_library(swiftRuntimeCMakeConfig INTERFACE)
6+
target_include_directories(swiftRuntimeCMakeConfig INTERFACE
7+
$<$<COMPILE_LANGUAGE:C,CXX,Swift>:$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>>)
8+
59
add_library(swiftRuntime OBJECT
610
"${PROJECT_SOURCE_DIR}/CompatibilityOverride/CompatibilityOverride.cpp"
711
AnyHashableSupport.cpp
@@ -132,6 +136,14 @@ if(SwiftCore_ENABLE_OBJC_INTEROP)
132136
ObjCRuntimeGetImageNameFromClass.mm)
133137
endif()
134138

139+
install(FILES
140+
"${PROJECT_BINARY_DIR}/include/swift/Runtime/CMakeConfig.h"
141+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/swift/Runtime"
142+
COMPONENT SwiftCore_development)
143+
install(TARGETS swiftRuntimeCMakeConfig
144+
EXPORT SwiftCoreTargets
145+
COMPONENT SwiftCore_development)
146+
135147
if(NOT BUILD_SHARED_LIBS)
136148
install(TARGETS swiftRuntime
137149
EXPORT SwiftCoreTargets

Runtimes/Supplemental/Distributed/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ target_link_libraries(swiftDistributed PRIVATE
143143
swift_Concurrency
144144
swift_Builtin_float
145145
$<$<PLATFORM_ID:Android>:swiftAndroid>
146-
$<$<PLATFORM_ID:Windows>:swiftWinSDK>)
147-
# swiftDarwin/Libc/Platform
146+
$<$<PLATFORM_ID:Windows>:swiftWinSDK>
147+
$<$<PLATFORM_ID:Darwin>:swiftDarwin>)
148148

149149
install(TARGETS swiftDistributed
150150
EXPORT SwiftDistributedTargets

Runtimes/Supplemental/cmake/modules/FindSwiftCore.cmake

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,15 @@ endif()
287287
find_path(SwiftShims_INCLUDE_DIR "shims/module.modulemap" HINTS
288288
${SwiftShims_INCLUDE_DIR_HINTS})
289289
add_library(swiftShims INTERFACE IMPORTED GLOBAL)
290-
set_target_properties(swiftShims PROPERTIES
291-
INTERFACE_INCLUDE_DIRECTORIES "${SwiftShims_INCLUDE_DIR}/shims")
290+
target_include_directories(swiftShims INTERFACE
291+
# This is needed for targets that import headers from
292+
# include/swift (e.g. include/swift/ABI/HeapObject.h)
293+
# that assumes the shims are located in `swift/shims`
294+
# relative path
295+
"${SwiftShims_INCLUDE_DIR}/.."
296+
"${SwiftShims_INCLUDE_DIR}/shims")
297+
target_compile_options(swiftShims INTERFACE
298+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -fmodule-map-file=\"${SwiftShims_INCLUDE_DIR}/shims/module.modulemap\">")
292299

293300
find_package_handle_standard_args(SwiftCore DEFAULT_MSG
294301
SwiftCore_LIBRARY SwiftCore_INCLUDE_DIR

0 commit comments

Comments
 (0)