Merge pull request #83447 from compnerd/volatile

Runtimes: add a build for _Volatile
This commit is contained in:
Saleem Abdulrasool
2025-08-04 14:49:39 -07:00
committed by GitHub
5 changed files with 154 additions and 44 deletions

View File

@@ -96,11 +96,23 @@ endforeach()
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Core/Info.plist.in")
copy_files("" "Core" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Distributed/Info.plist.in")
copy_files("" "Supplemental/Distributed" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Differentiation/Info.plist.in")
copy_files("" "Supplemental/Differentiation" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Observation/Info.plist.in")
copy_files("" "Supplemental/Observation" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/StringProcessing/Info.plist.in")
copy_files("" "Supplemental/StringProcessing" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Synchronization/Info.plist.in")
copy_files("" "Supplemental/Synchronization" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Distributed/Info.plist.in")
copy_files("" "Supplemental/Distributed" FILES "Info.plist.in")
message(STATUS "plist[${StdlibSources}/Info.plist.in] -> Supplemental/Volatile/Info.plist.in")
copy_files("" "Supplemental/Volatile" FILES "Info.plist.in")
# Platform Overlays
@@ -155,15 +167,6 @@ copy_files(public/Platform Overlay/Windows/CRT
TiocConstants.swift
tgmath.swift.gyb)
# Supplemental Libraries
copy_library_sources(Synchronization "public" "Supplemental")
copy_library_sources(Observation "public" "Supplemental")
# Copy Differentiation sources
copy_library_sources("linker-support" "" "Supplemental/Differentiation")
copy_library_sources("Differentiation" "public" "Supplemental")
# Copy StringProcessing, RegexParser, RegexBuilder
if(NOT DEFINED StringProcessing_ROOT_DIR)
find_path(StringProcessing_ROOT_DIR
"swift-experimental-string-processing/Package.swift"
@@ -171,6 +174,13 @@ if(NOT DEFINED StringProcessing_ROOT_DIR)
endif()
message(STATUS "String Processing Root: ${StringProcessing_ROOT_DIR}")
# Supplemental Libraries
copy_library_sources(Differentiation "public" "Supplemental")
copy_library_sources(Distributed "public" "Supplemental")
copy_library_sources(Observation "public" "Supplemental")
copy_library_sources(Synchronization "public" "Supplemental")
copy_library_sources(Volatile "public" "Supplemental")
copy_library_sources(_RegexParser "Sources" "Supplemental/StringProcessing"
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
copy_library_sources(_StringProcessing "Sources" "Supplemental/StringProcessing"
@@ -180,5 +190,5 @@ copy_library_sources(_CUnicode "Sources" "Supplemental/StringProcessing/_StringP
copy_library_sources(RegexBuilder "Sources" "Supplemental/StringProcessing"
ROOT "${StringProcessing_ROOT_DIR}/swift-experimental-string-processing")
copy_library_sources("Distributed" "public" "Supplemental")
copy_library_sources("linker-support" "" "Supplemental/Differentiation")
copy_library_sources(include "" "Supplemental/Distributed")

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>@PLIST_INFO_UTI@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>@PLIST_INFO_NAME@</string>
<key>CFBundleShortVersionString</key>
<string>@PLIST_INFO_VERSION@</string>
<key>CFBundleVersion</key>
<string>@PLIST_INFO_BUILD_VERSION@</string>
</dict>
</plist>

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIdentifier</key>
<string>@PLIST_INFO_UTI@</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>@PLIST_INFO_NAME@</string>
<key>CFBundleShortVersionString</key>
<string>@PLIST_INFO_VERSION@</string>
<key>CFBundleVersion</key>
<string>@PLIST_INFO_BUILD_VERSION@</string>
</dict>
</plist>

View File

@@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 3.29)
# TODO before requiring CMake 4.1 or later
# and/or enforcing CMP0195, please check/update
# the implementation of `emit_swift_interface`
# in `EmitSwiftInterface.cmake`
# to ensure it keeps laying down nested swiftmodule folders
if(POLICY CMP0157 AND CMAKE_Swift_COMPILER_USE_OLD_DRIVER)
cmake_policy(SET CMP0157 OLD)
endif()
if($ENV{BUILD_NUMBER})
math(EXPR BUILD_NUMBER "$ENV{BUILD_NUMBER} % 65535")
set(BUILD_NUMBER ".${BUILD_NUMBER}")
endif()
project(SwiftVolatile
LANGUAGES Swift
VERSION 6.1.0${BUILD_NUMBER})
# FIXME(compnerd) this is a workaround for `GNUInstallDirs` which cannot be used
# with a pure Swift project.
enable_language(C)
if(NOT PROJECT_IS_TOP_LEVEL)
message(SEND_ERROR "Swift Observation must build as a standalone project")
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../cmake/modules")
set(${PROJECT_NAME}_SWIFTC_SOURCE_DIR
"${PROJECT_SOURCE_DIR}/../../../"
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
# Hook point for vendor-specific extensions to the build system
# Allowed extension points:
# - DefaultSettings.cmake
# - Settings.cmake
set(${PROJECT_NAME}_VENDOR_MODULE_DIR "${CMAKE_SOURCE_DIR}/../cmake/modules/vendor"
CACHE FILEPATH "Location for private build system extension")
find_package(SwiftCore REQUIRED)
find_package(SwiftOverlay REQUIRED)
include(GNUInstallDirs)
include(AvailabilityMacros)
include(EmitSwiftInterface)
include(InstallSwiftInterface)
include(PlatformInfo)
include(gyb)
include(ResourceEmbedding)
include(CatalystSupport)
option(${PROJECT_NAME}_INSTALL_NESTED_SUBDIR "Install libraries under a platform and architecture subdirectory" ON)
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 "")
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 "")
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/Settings.cmake" OPTIONAL)
option(${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries"
${SwiftCore_ENABLE_LIBRARY_EVOLUTION})
option(${PROJECT_NAME}_ENABLE_PRESPECIALIZATION "Enable generic metadata prespecialization"
${SwiftCore_ENABLE_PRESPECIALIZATION})
add_compile_options(
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
$<$<COMPILE_LANGUAGE:Swift>:-nostdlibimport>
$<$<COMPILE_LANGUAGE:Swift>:-enable-builtin-module>
$<$<COMPILE_LANGUAGE:Swift>:-strict-memory-safety>
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_LIBRARY_EVOLUTION}>,$<COMPILE_LANGUAGE:Swift>>:-enable-library-evolution>"
"$<$<AND:$<BOOL:${${PROJECT_NAME}_ENABLE_PRESPECIALIZATION}>,$<COMPILE_LANGUAGE:Swift>>:SHELL:-Xfrontend -prespecialize-generic-metadata>")
# LNK4049: symbol 'symbol' defined in 'filename.obj' is imported
# LNK4286: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj'
# LNK4217: symbol 'symbol' defined in 'filename_1.obj' is imported by 'filename_2.obj' in function 'function'
#
# We cannot selectively filter the linker warnings as we do not use the MSVC
# frontned and `clang-cl` (and `clang`) currently do not support `/WX:nnnn`. As
# a compromise, treat all linker warnings as errors.
add_link_options($<$<PLATFORM_ID:Windows>:LINKER:/WX>)
add_library(swift_Volatile
Volatile.swift)
set_target_properties(swift_Volatile PROPERTIES
Swift_MODULE_NAME _Volatile)
target_compile_options(swift_Volatile PRIVATE
-parse-stdlib)
target_link_libraries(swift_Volatile PRIVATE
swiftCore)
install(TARGETS swift_Volatile
EXPORT SwiftVolatileTargets
COMPONENT ${PROJECT_NAME}_runtime
ARCHIVE DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${${PROJECT_NAME}_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
emit_swift_interface(swift_Volatile)
install_swift_interface(swift_Volatile)
# Configure plist creation for Darwin platforms.
generate_plist("${CMAKE_PROJECT_NAME}" "${CMAKE_PROJECT_VERSION}" swift_Volatile)
embed_manifest(swift_Volatile)
include("${${PROJECT_NAME}_VENDOR_MODULE_DIR}/swift_Volatile.cmake" OPTIONAL)

View File

@@ -733,6 +733,7 @@ enum Project {
ExperimentalStaticDistributed
ExperimentalStaticObservation
ExperimentalStaticDifferentiation
ExperimentalStaticVolatile
ExperimentalStaticDispatch
ExperimentalStaticFoundation
}
@@ -2498,6 +2499,12 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
throw "dynamic Experimental Differentiation is not yet implemented"
}
$VolatileBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticVolatile
} else {
throw "dynamic Experimental Volatile is not yet implemented"
}
Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Core `
-Bin $RuntimeBinaryCache `
@@ -2619,6 +2626,27 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
}
Build-CMakeProject `
-Src $SourceCache\swift\Runtimes\Supplemental\Volatile `
-Bin $VolatileBinaryCache `
-InstallTo "${SDKROOT}\usr" `
-Platform $Platform `
-UseBuiltCompilers C,Swift `
-SwiftSDK $null `
-UseGNUDriver `
-Defines @{
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_Swift_COMPILER_TARGET = (Get-ModuleTriple $Platform);
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
SwiftOverlay_DIR = "${OverlayBinaryCache}\cmake\SwiftOverlay";
# FIXME(compnerd) this currently causes a build failure on Windows, but
# this should be enabled when building the dynamic runtime.
SwiftVolatile_ENABLE_LIBRARY_EVOLUTION = "NO";
}
}
}