Skip to content

Commit b982f16

Browse files
authored
Merge pull request #83447 from compnerd/volatile
Runtimes: add a build for _Volatile
2 parents b7709d9 + 60fb1cd commit b982f16

File tree

5 files changed

+154
-44
lines changed

5 files changed

+154
-44
lines changed

Runtimes/Resync.cmake

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,23 @@ endforeach()
9696
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Core/Info.plist.in")
9797
copy_files("" "Core" FILES "Info.plist.in")
9898

99+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Distributed/Info.plist.in")
100+
copy_files("" "Supplemental/Distributed" FILES "Info.plist.in")
101+
102+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Differentiation/Info.plist.in")
103+
copy_files("" "Supplemental/Differentiation" FILES "Info.plist.in")
104+
105+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Observation/Info.plist.in")
106+
copy_files("" "Supplemental/Observation" FILES "Info.plist.in")
107+
108+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/StringProcessing/Info.plist.in")
109+
copy_files("" "Supplemental/StringProcessing" FILES "Info.plist.in")
110+
99111
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Synchronization/Info.plist.in")
100112
copy_files("" "Supplemental/Synchronization" FILES "Info.plist.in")
101113

102-
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Distributed/Info.plist.in")
103-
copy_files("" "Supplemental/Distributed" FILES "Info.plist.in")
114+
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Volatile/Info.plist.in")
115+
copy_files("" "Supplemental/Volatile" FILES "Info.plist.in")
104116

105117
# Platform Overlays
106118

@@ -155,22 +167,20 @@ copy_files(public/Platform Overlay/Windows/CRT
155167
TiocConstants.swift
156168
tgmath.swift.gyb)
157169

158-
# Supplemental Libraries
159-
copy_library_sources(Synchronization "public" "Supplemental")
160-
copy_library_sources(Observation "public" "Supplemental")
161-
162-
# Copy Differentiation sources
163-
copy_library_sources("linker-support" "" "Supplemental/Differentiation")
164-
copy_library_sources("Differentiation" "public" "Supplemental")
165-
166-
# Copy StringProcessing, RegexParser, RegexBuilder
167170
if(NOT DEFINED StringProcessing_ROOT_DIR)
168171
find_path(StringProcessing_ROOT_DIR
169172
"swift-experimental-string-processing/Package.swift"
170173
HINTS "${CMAKE_CURRENT_LIST_DIR}/../../")
171174
endif()
172175
message(STATUS "String Processing Root: ${StringProcessing_ROOT_DIR}")
173176

177+
# Supplemental Libraries
178+
copy_library_sources(Differentiation "public" "Supplemental")
179+
copy_library_sources(Distributed "public" "Supplemental")
180+
copy_library_sources(Observation "public" "Supplemental")
181+
copy_library_sources(Synchronization "public" "Supplemental")
182+
copy_library_sources(Volatile "public" "Supplemental")
183+
174184
copy_library_sources(_RegexParser "Sources" "Supplemental/StringProcessing"
175185
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
176186
copy_library_sources(_StringProcessing "Sources" "Supplemental/StringProcessing"
@@ -180,5 +190,5 @@ copy_library_sources(_CUnicode "Sources" "Supplemental/StringProcessing/_StringP
180190
copy_library_sources(RegexBuilder "Sources" "Supplemental/StringProcessing"
181191
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
182192

183-
copy_library_sources("Distributed" "public" "Supplemental")
193+
copy_library_sources("linker-support" "" "Supplemental/Differentiation")
184194
copy_library_sources(include "" "Supplemental/Distributed")

Runtimes/Supplemental/Differentiation/Info.plist.in

Lines changed: 0 additions & 16 deletions
This file was deleted.

Runtimes/Supplemental/Observation/Info.plist.in

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
cmake_minimum_required(VERSION 3.29)
2+
# TODO before requiring CMake 4.1 or later
3+
# and/or enforcing CMP0195, please check/update
4+
# the implementation of `emit_swift_interface`
5+
# in `EmitSwiftInterface.cmake`
6+
# to ensure it keeps laying down nested swiftmodule folders
7+
8+
if(POLICY CMP0157 AND CMAKE_Swift_COMPILER_USE_OLD_DRIVER)
9+
cmake_policy(SET CMP0157 OLD)
10+
endif()
11+
12+
if($ENV{BUILD_NUMBER})
13+
math(EXPR BUILD_NUMBER "$ENV{BUILD_NUMBER} % 65535")
14+
set(BUILD_NUMBER ".${BUILD_NUMBER}")
15+
endif()
16+
project(SwiftVolatile
17+
LANGUAGES Swift
18+
VERSION 6.1.0${BUILD_NUMBER})
19+
# FIXME(compnerd) this is a workaround for `GNUInstallDirs` which cannot be used
20+
# with a pure Swift project.
21+
enable_language(C)
22+
23+
if(NOT PROJECT_IS_TOP_LEVEL)
24+
message(SEND_ERROR "Swift Observation must build as a standalone project")
25+
endif()
26+
27+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake/modules")
28+
29+
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR
30+
"${PROJECT_SOURCE_DIR}/../../../"
31+
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
32+
33+
# Hook point for vendor-specific extensions to the build system
34+
# Allowed extension points:
35+
# - DefaultSettings.cmake
36+
# - Settings.cmake
37+
set(${PROJECT_NAME}_VENDOR_MODULE_DIR "${CMAKE_SOURCE_DIR}/../cmake/modules/vendor"
38+
CACHE FILEPATH "Location for private build system extension")
39+
40+
find_package(SwiftCore REQUIRED)
41+
find_package(SwiftOverlay REQUIRED)
42+
43+
include(GNUInstallDirs)
44+
45+
include(AvailabilityMacros)
46+
include(EmitSwiftInterface)
47+
include(InstallSwiftInterface)
48+
include(PlatformInfo)
49+
include(gyb)
50+
include(ResourceEmbedding)
51+
include(CatalystSupport)
52+
53+
option(${PROJECT_NAME}_INSTALL_NESTED_SUBDIR "Install libraries under a platform and architecture subdirectory" ON)
54+
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}/${${PROJECT_NAME}_ARCH_SUBDIR}>" CACHE STRING "")
55+
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 "")
56+
57+
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL)
58+
59+
option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries"
60+
${SwiftCore_ENABLE_LIBRARY_EVOLUTION})
61+
62+
option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization"
63+
${SwiftCore_ENABLE_PRESPECIALIZATION})
64+
65+
add_compile_options(
66+
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
67+
$<$<COMPILE_LANGUAGE:Swift>:-nostdlibimport>
68+
$<$<COMPILE_LANGUAGE:Swift>:-enable-builtin-module>
69+
$<$<COMPILE_LANGUAGE:Swift>:-strict-memory-safety>
70+
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION}>,$<COMPILE_LANGUAGE:Swift>>:-enable-library-evolution>"
71+
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_PRESPECIALIZATION}>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xfrontend -prespecialize-generic-metadata>")
72+
73+
# LNK4049: symbol 'symbol' defined in 'filename.obj' is imported
74+
# LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj'
75+
# LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function'
76+
#
77+
# We cannot selectively filter the linker warnings as we do not use the MSVC
78+
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
79+
# a compromise, treat all linker warnings as errors.
80+
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
81+
82+
add_library(swift_Volatile
83+
Volatile.swift)
84+
set_target_properties(swift_Volatile PROPERTIES
85+
Swift_MODULE_NAME _Volatile)
86+
target_compile_options(swift_Volatile PRIVATE
87+
-parse-stdlib)
88+
target_link_libraries(swift_Volatile PRIVATE
89+
swiftCore)
90+
91+
install(TARGETS swift_Volatile
92+
EXPORT SwiftVolatileTargets
93+
COMPONENT ${PROJECT_NAME}_runtime
94+
ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
95+
LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
96+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
97+
emit_swift_interface(swift_Volatile)
98+
install_swift_interface(swift_Volatile)
99+
100+
# Configure plist creation for Darwin platforms.
101+
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swift_Volatile)
102+
embed_manifest(swift_Volatile)
103+
104+
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/swift_Volatile.cmake" OPTIONAL)

utils/build.ps1

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ enum Project {
733733
ExperimentalStaticDistributed
734734
ExperimentalStaticObservation
735735
ExperimentalStaticDifferentiation
736+
ExperimentalStaticVolatile
736737
ExperimentalStaticDispatch
737738
ExperimentalStaticFoundation
738739
}
@@ -2498,6 +2499,12 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
24982499
throw "dynamic Experimental Differentiation is not yet implemented"
24992500
}
25002501

2502+
$VolatileBinaryCache = if ($Static) {
2503+
Get-ProjectBinarycache $Platform ExperimentalStaticVolatile
2504+
} else {
2505+
throw "dynamic Experimental Volatile is not yet implemented"
2506+
}
2507+
25012508
Build-CMakeProject `
25022509
-Src $SourceCache\swift\Runtimes\Core `
25032510
-Bin $RuntimeBinaryCache `
@@ -2619,6 +2626,27 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
26192626
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
26202627
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
26212628
}
2629+
2630+
Build-CMakeProject `
2631+
-Src $SourceCache\swift\Runtimes\Supplemental\Volatile `
2632+
-Bin $VolatileBinaryCache `
2633+
-InstallTo "${SDKROOT}\usr" `
2634+
-Platform $Platform `
2635+
-UseBuiltCompilers C,Swift `
2636+
-SwiftSDK $null `
2637+
-UseGNUDriver `
2638+
-Defines @{
2639+
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2640+
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
2641+
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
2642+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2643+
2644+
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
2645+
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
2646+
# FIXME(compnerd) this currently causes a build failure on Windows, but
2647+
# this should be enabled when building the dynamic runtime.
2648+
SwiftVolatile_ENABLE_LIBRARY_EVOLUTION = "NO";
2649+
}
26222650
}
26232651
}
26242652

0 commit comments

Comments
 (0)