Skip to content

Commit 4923ce8

Browse files
authored
Merge pull request #81529 from edymtt/edymtt/add-distributed-to-new-build-system-inert
[Runtimes][CMake] Add Distributed to Supplemental build
2 parents 22f32e0 + 7348469 commit 4923ce8

File tree

9 files changed

+177
-29
lines changed

9 files changed

+177
-29
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,4 @@ Runtimes/**/*.json
9898
Runtimes/**/*.modulemap
9999
Runtimes/**/*.in
100100
!Runtimes/**/*.cmake.in
101+
!Runtimes/**/CMakeConfig.h.in

Runtimes/Core/runtime/CMakeConfig.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#ifndef SWIFT_RUNTIME_CMAKECONFIG_H
55
#define SWIFT_RUNTIME_CMAKECONFIG_H
66

7-
#cmakedefine01 SWIFT_BNI_OS_BUILD
8-
#cmakedefine01 SWIFT_BNI_XCODE_BUILD
9-
107
#define SWIFT_VERSION_MAJOR "@SwiftCore_VERSION_MAJOR@"
118
#define SWIFT_VERSION_MINOR "@SwiftCore_VERSION_MINOR@"
129

Runtimes/Core/runtime/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
# TODO: clean this up so it's less Apple-specific.
2-
# Detect B&I builds.
3-
set(SWIFT_BNI_OS_BUILD FALSE)
4-
set(SWIFT_BNI_XCODE_BUILD FALSE)
5-
if(DEFINED ENV{RC_XBS})
6-
if((NOT DEFINED ENV{RC_XCODE} OR NOT "$ENV{RC_XCODE}") AND (NOT DEFINED ENV{RC_PLAYGROUNDS} OR NOT "$ENV{RC_PLAYGROUNDS}"))
7-
set(SWIFT_BNI_OS_BUILD TRUE)
8-
else()
9-
set(SWIFT_BNI_XCODE_BUILD TRUE)
10-
endif()
11-
endif()
12-
131
configure_file("CMakeConfig.h.in"
142
"${PROJECT_BINARY_DIR}/include/swift/Runtime/CMakeConfig.h"
153
ESCAPE_QUOTES @ONLY)

Runtimes/Resync.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ copy_files("" "Core" FILES "Info.plist.in")
9999
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Synchronization/Info.plist.in")
100100
copy_files("" "Supplemental/Synchronization" FILES "Info.plist.in")
101101

102+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Distributed/Info.plist.in")
103+
copy_files("" "Supplemental/Distributed" FILES "Info.plist.in")
104+
102105
# Platform Overlays
103106

104107
# Copy magic linker symbols
@@ -175,3 +178,6 @@ copy_library_sources(_CUnicode "Sources" "Supplemental/StringProcessing/_StringP
175178
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
176179
copy_library_sources(RegexBuilder "Sources" "Supplemental/StringProcessing"
177180
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
181+
182+
copy_library_sources("Distributed" "public" "Supplemental")
183+
copy_library_sources(include "" "Supplemental/Distributed")

Runtimes/Supplemental/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,14 @@ if(SwiftRuntime_ENABLE_synchronization)
6969
CMAKE_ARGS
7070
${COMMON_OPTIONS})
7171
endif()
72+
73+
# Distributed
74+
if(SwiftRuntime_ENABLE_distributed)
75+
ExternalProject_Add(Distributed
76+
PREFIX "Distributed"
77+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Distributed"
78+
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
79+
INSTALL_COMMAND ""
80+
CMAKE_ARGS
81+
${COMMON_OPTIONS})
82+
endif()
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
cmake_minimum_required(VERSION 3.29)
2+
3+
if(POLICY CMP0157 AND CMAKE_Swift_COMPILER_USE_OLD_DRIVER)
4+
cmake_policy(SET CMP0157 OLD)
5+
endif()
6+
7+
if($ENV{BUILD_NUMBER})
8+
math(EXPR BUILD_NUMBER "$ENV{BUILD_NUMBER} % 65535")
9+
set(BUILD_NUMBER ".${BUILD_NUMBER}")
10+
endif()
11+
project(SwiftDistributed
12+
LANGUAGES C CXX Swift
13+
VERSION 6.3.0${BUILD_NUMBER})
14+
15+
if(NOT PROJECT_IS_TOP_LEVEL)
16+
message(SEND_ERROR "Swift Distributed must build as a standalone project")
17+
endif()
18+
19+
set(CMAKE_Swift_LANGUAGE_VERSION 5)
20+
21+
set(CMAKE_POSITION_INDEPENDENT_CODE YES)
22+
set(CMAKE_C_VISIBILITY_PRESET "hidden")
23+
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
24+
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
25+
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
26+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
27+
set(CMAKE_CXX_EXTENSIONS NO)
28+
29+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake/modules")
30+
31+
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR
32+
"${PROJECT_SOURCE_DIR}/../../../"
33+
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
34+
35+
set(${PROJECT_NAME}_VENDOR_MODULE_DIR "${CMAKE_SOURCE_DIR}/../cmake/modules/vendor"
36+
CACHE FILEPATH "Location for private build system extension")
37+
38+
find_package(SwiftCore REQUIRED)
39+
40+
include(AvailabilityMacros)
41+
include(EmitSwiftInterface)
42+
include(InstallSwiftInterface)
43+
include(PlatformInfo)
44+
include(ResourceEmbedding)
45+
include(CatalystSupport)
46+
include(SwiftCallingConventions)
47+
48+
option(${PROJECT_NAME}_INSTALL_NESTED_SUBDIR "Install libraries under a platform and architecture subdirectory" ON)
49+
set(${PROJECT_NAME}_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${${PROJECT_NAME}_INSTALL_NESTED_SUBDIR}>:/${${PROJECT_NAME}_PLATFORM_SUBDIR}/${Supplemental_ARCH_SUBDIR}>" CACHE STRING "")
50+
set(${PROJECT_NAME}_INSTALL_SWIFTMODULEDIR "${CMAKE_INSTALL_LIBDIR}/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>$<$<BOOL:${${PROJECT_NAME}_INSTALL_NESTED_SUBDIR}>:/${${PROJECT_NAME}_PLATFORM_SUBDIR}>" CACHE STRING "")
51+
52+
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL)
53+
54+
option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries"
55+
${SwiftCore_ENABLE_LIBRARY_EVOLUTION})
56+
57+
option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization"
58+
${SwiftCore_ENABLE_PRESPECIALIZATION})
59+
60+
add_library(swiftDistributed
61+
DistributedActor.cpp
62+
DistributedActor.swift
63+
DistributedActorSystem.swift
64+
DistributedAssertions.swift
65+
DistributedDefaultExecutor.swift
66+
DistributedMacros.swift
67+
DistributedMetadata.swift
68+
LocalTestingDistributedActorSystem.swift)
69+
70+
target_compile_options(swiftDistributed PRIVATE
71+
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
72+
$<$<COMPILE_LANGUAGE:Swift>:-nostdlibimport>
73+
$<$<COMPILE_LANGUAGE:Swift>:-parse-stdlib>
74+
$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature AllowUnsafeAttribute>
75+
$<$<COMPILE_LANGUAGE:Swift>:-strict-memory-safety>
76+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-library-level api>"
77+
$<$<COMPILE_LANGUAGE:Swift>:-enforce-exclusivity=unchecked>
78+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -target-min-inlining-version -Xfrontend min>"
79+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-lexical-lifetimes=false>"
80+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NoncopyableGenerics2>"
81+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SuppressedAssociatedTypes>"
82+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SE427NoInferenceOnExtension>"
83+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NonescapableTypes>"
84+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependence>"
85+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature LifetimeDependenceMutableAccessors>"
86+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature MemberImportVisibility>"
87+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature InoutLifetimeDependence>"
88+
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION}>,$<COMPILE_LANGUAGE:Swift>>:-enable-library-evolution>"
89+
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_PRESPECIALIZATION}>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xfrontend -prespecialize-generic-metadata>")
90+
91+
set_target_properties(swiftDistributed PROPERTIES
92+
Swift_MODULE_NAME Distributed
93+
LINKER_LANGUAGE CXX)
94+
95+
if(APPLE AND BUILD_SHARED_LIBS)
96+
target_link_options(swiftDistributed PRIVATE "SHELL:-Xlinker -headerpad_max_install_names")
97+
endif()
98+
99+
target_compile_definitions(swiftDistributed PRIVATE
100+
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftDistributed>)
101+
102+
target_include_directories(swiftDistributed PRIVATE
103+
# FIXME: Use of `swift/Runtime/...`, `swift/ABI/...`, and `swift/Demangling/...`
104+
"${${PROJECT_NAME}_SWIFTC_SOURCE_DIR}/include"
105+
# For `swift/runtime/CMakeConfig.h`, which should be generated
106+
# by the Core build system.
107+
"${${PROJECT_NAME}_PATH_TO_SWIFT_RUNTIME_HEADERS}"
108+
# For llvm/support headers
109+
"${PROJECT_SOURCE_DIR}/include")
110+
111+
target_link_libraries(swiftDistributed PRIVATE
112+
swiftShims
113+
swiftCore
114+
swift_Concurrency)
115+
# swiftDarwin/Libc/Platform
116+
# builtin_float
117+
118+
install(TARGETS swiftDistributed
119+
EXPORT SwiftDistributedTargets
120+
COMPONENT ${PROJECT_NAME}_runtime
121+
ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
122+
LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
123+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
124+
emit_swift_interface(swiftDistributed)
125+
install_swift_interface(swiftDistributed)
126+
127+
# Configure plist creation for Darwin platforms.
128+
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swiftDistributed)
129+
embed_manifest(swiftDistributed)
130+
131+
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/swiftDistributed.cmake" OPTIONAL)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
include(CheckSourceCompiles)
2+
include(CheckCompilerFlag)
3+
4+
check_source_compiles(CXX
5+
"#if !(__has_attribute(swiftcall) && \
6+
__has_attribute(swift_context) && \
7+
__has_attribute(swift_error_result) && \
8+
__has_attribute(swift_indirect_result))
9+
#error CXX compiler must support Swift calling conventions
10+
#endif
11+
int main(void) { return 0; }"
12+
HAVE_SWIFTCALL)
13+
14+
if(NOT HAVE_SWIFTCALL)
15+
message(SEND_ERROR "CXX Compiler must support Swift calling conventions")
16+
endif()
17+
18+
check_source_compiles(CXX
19+
"#if !(__has_attribute(swiftasynccall) && \
20+
__has_attribute(swift_async_context))
21+
#error CXX compiler must support Swift async calling conventions
22+
#endif
23+
int main(void) { return 0; }"
24+
HAVE_SWIFT_ASYNC_CALL)
25+
26+
if(NOT HAVE_SWIFT_ASYNC_CALL)
27+
message(SEND_ERROR "CXX Compiler must support Swift async calling conventions")
28+
endif()

include/swift/Runtime/CMakeConfig.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
#ifndef SWIFT_RUNTIME_CMAKECONFIG_H
55
#define SWIFT_RUNTIME_CMAKECONFIG_H
66

7-
#cmakedefine01 SWIFT_BNI_OS_BUILD
8-
#cmakedefine01 SWIFT_BNI_XCODE_BUILD
9-
107
#define SWIFT_VERSION_MAJOR "@SWIFT_VERSION_MAJOR@"
118
#define SWIFT_VERSION_MINOR "@SWIFT_VERSION_MINOR@"
129

include/swift/Runtime/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
# Detect B&I builds.
2-
set(SWIFT_BNI_OS_BUILD FALSE)
3-
set(SWIFT_BNI_XCODE_BUILD FALSE)
4-
if(DEFINED ENV{RC_XBS})
5-
if((NOT DEFINED ENV{RC_XCODE} OR NOT "$ENV{RC_XCODE}") AND (NOT DEFINED ENV{RC_PLAYGROUNDS} OR NOT "$ENV{RC_PLAYGROUNDS}"))
6-
set(SWIFT_BNI_OS_BUILD TRUE)
7-
else()
8-
set(SWIFT_BNI_XCODE_BUILD TRUE)
9-
endif()
10-
endif()
11-
121
configure_file(CMakeConfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/CMakeConfig.h
132
ESCAPE_QUOTES @ONLY)
143
swift_install_in_component(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeConfig.h

0 commit comments

Comments
 (0)