Skip to content

utils: build the dynamic experimental SDK #83717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 126 additions & 11 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,16 @@ enum Project {
ClangBuiltins
ClangRuntime
SwiftInspect
ExperimentalDynamicRuntime
ExperimentalDynamicOverlay
ExperimentalDynamicStringProcessing
ExperimentalDynamicSynchronization
ExperimentalDynamicDistributed
ExperimentalDynamicObservation
ExperimentalDynamicDispatch
ExperimentalDynamicDifferentiation
ExperimentalDynamicVolatile
ExperimentalDynamicFoundation
ExperimentalStaticRuntime
ExperimentalStaticOverlay
ExperimentalStaticStringProcessing
Expand Down Expand Up @@ -2516,49 +2526,49 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
$RuntimeBinaryCache = if ($Static) {
Get-ProjectBinaryCache $Platform ExperimentalStaticRuntime
} else {
throw "dynamic Experimental Runtime is not yet implemented"
Get-ProjectBinaryCache $Platform ExperimentalDynamicRuntime
}

$OverlayBinaryCache = if ($Static) {
Get-ProjectBinaryCache $Platform ExperimentalStaticOverlay
} else {
throw "dynamic Experimental Runtime is not yet implemented"
Get-ProjectBinarycache $Platform ExperimentalDynamicOverlay
}

$StringProcessingBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticStringProcessing
} else {
throw "dynamic Experimental Runtime is not yet implemented"
Get-ProjectBinarycache $Platform ExperimentalDynamicStringProcessing
}

$SynchronizationBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticSynchronization
} else {
throw "dynamic Experimental Runtime is not yet implemented"
Get-ProjectBinarycache $Platform ExperimentalDynamicSynchronization
}

$DistributedBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticDistributed
} else {
throw "dynamic Experimental Runtime is not yet implemented"
Get-ProjectBinarycache $Platform ExperimentalDynamicDistributed
}

$ObservationBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticObservation
} else {
throw "dynamic Experimental Runtime is not yet implemented"
Get-ProjectBinaryCache $Platform ExperimentalDynamicObservation
}

$DifferentiationBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticDifferentiation
} else {
throw "dynamic Experimental Differentiation is not yet implemented"
Get-ProjectBinarycache $Platform ExperimentalDynamicDifferentiation
}

$VolatileBinaryCache = if ($Static) {
Get-ProjectBinarycache $Platform ExperimentalStaticVolatile
} else {
throw "dynamic Experimental Volatile is not yet implemented"
Get-ProjectBinaryCache $Platform ExperimentalDynamicVolatile
}

Build-CMakeProject `
Expand All @@ -2579,6 +2589,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
SwiftCore_ENABLE_CONCURRENCY = "YES";
# FIXME(compnerd) remove this once the default option is flipped to `ON`.
SwiftCore_ENABLE_REMOTE_MIRROR = "YES";
# FIXME(compnerd) this currently causes a build failure on Windows, but
# this should be enabled when building the dynamic runtime.
SwiftCore_ENABLE_LIBRARY_EVOLUTION = "NO";
}

Build-CMakeProject `
Expand All @@ -2595,6 +2608,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa

SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";

# FIXME(compnerd) this currently causes a build failure on Windows, but
# this should be enabled when building the dynamic runtime.
SwiftOverlay_ENABLE_LIBRARY_EVOLUTION = "NO";
SwiftOverlay_ENABLE_CXX_INTEROP = "YES";
}

Expand All @@ -2611,6 +2627,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";

SwiftCore_DIR = "${RuntimeBinaryCache}\cmake\SwiftCore";
# FIXME(compnerd) this currently causes a build failure on Windows, but
# this should be enabled when building the dynamic runtime.
SwiftStringProcessing_ENABLE_LIBRARY_EVOLUTION = "NO";
}

Build-CMakeProject `
Expand All @@ -2627,6 +2646,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa

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.
SwiftSynchronization_ENABLE_LIBRARY_EVOLUTION = "NO";
}

Build-CMakeProject `
Expand All @@ -2645,6 +2667,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa

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.
SwiftDistributed_ENABLE_LIBRARY_EVOLUTION = "NO";
}

Build-CMakeProject `
Expand All @@ -2663,6 +2688,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa

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.
SwiftObservation_ENABLE_LIBRARY_EVOLUTION = "NO";
}

Build-CMakeProject `
Expand All @@ -2679,6 +2707,9 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa

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.
SwiftDifferentiation_ENABLE_LIBRARY_EVOLUTION = "NO";
}

Build-CMakeProject `
Expand Down Expand Up @@ -3024,12 +3055,27 @@ function Build-SDK([Hashtable] $Platform, [switch] $IncludeMacros = $false) {
function Build-ExperimentalSDK([Hashtable] $Platform) {
Invoke-BuildStep Build-CDispatch $Platform

# TODO(compnerd) we currently build the experimental SDK with just the static
# variant. We should aim to build both dynamic and static variants.
Invoke-BuildStep Build-ExperimentalRuntime $Platform
Invoke-BuildStep Build-ExperimentalRuntime $Platform -Static

Invoke-IsolatingEnvVars {
$env:Path = "$(Get-CMarkBinaryCache $Platform)\src;$(Get-PinnedToolchainRuntime);${env:Path}"

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-libdispatch `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalDynamicDispatch) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Platform $Platform `
-UseBuiltCompilers C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental") `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";

ENABLE_SWIFT = "YES";
}

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-libdispatch `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticDispatch) `
Expand All @@ -3046,7 +3092,66 @@ function Build-ExperimentalSDK([Hashtable] $Platform) {
}
}

Invoke-BuildStep Build-Foundation $Platform -Static
Build-CMakeProject `
-Src $SourceCache\swift-corelibs-foundation `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalDynamicFoundation) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Platform $Platform `
-UseBuiltCompilers ASM,C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental") `
-Defines @{
BUILD_SHARED_LIBS = "YES";
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
ENABLE_TESTING = "NO";

FOUNDATION_BUILD_TOOLS = "NO";
CURL_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\CURL";
LibXml2_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\libxml2-2.11.5";
ZLIB_INCLUDE_DIR = "$BinaryCache\$($Platform.Triple)\usr\include";
ZLIB_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
"$BinaryCache\$($Platform.Triple)\usr\lib\zlibstatic.lib"
} else {
"$BinaryCache\$($Platform.Triple)\usr\lib\libz.a"
};
dispatch_DIR = $(Get-ProjectCMakeModules $Platform ExperimentalDynamicDispatch);
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildPlatform FoundationMacros)\bin"
}

Build-CMakeProject `
-Src $SourceCache\swift-corelibs-foundation `
-Bin (Get-ProjectBinaryCache $Platform ExperimentalStaticFoundation) `
-InstallTo "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" `
-Platform $Platform `
-UseBuiltCompilers ASM,C,CXX,Swift `
-SwiftSDK (Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental") `
-Defines @{
BUILD_SHARED_LIBS = "NO";
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
CMAKE_Swift_FLAGS = @("-static-stdlib", "-Xfrontend", "-use-static-resource-dir");
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
ENABLE_TESTING = "NO";

FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS]::Windows) { "YES" } else { "NO" };
CURL_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\CURL";
LibXml2_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\libxml2-2.11.5";
ZLIB_INCLUDE_DIR = "$BinaryCache\$($Platform.Triple)\usr\include";
ZLIB_LIBRARY = if ($Platform.OS -eq [OS]::Windows) {
"$BinaryCache\$($Platform.Triple)\usr\lib\zlibstatic.lib"
} else {
"$BinaryCache\$($Platform.Triple)\usr\lib\libz.a"
};
dispatch_DIR = $(Get-ProjectCMakeModules $Platform ExperimentalStaticDispatch);
SwiftSyntax_DIR = (Get-ProjectBinaryCache $HostPlatform Compilers);
_SwiftFoundation_SourceDIR = "$SourceCache\swift-foundation";
_SwiftFoundationICU_SourceDIR = "$SourceCache\swift-foundation-icu";
_SwiftCollections_SourceDIR = "$SourceCache\swift-collections";
SwiftFoundation_MACRO = "$(Get-ProjectBinaryCache $BuildPlatform FoundationMacros)\bin"
}
}

function Build-SQLite([Hashtable] $Platform) {
Expand Down Expand Up @@ -3759,6 +3864,11 @@ if (-not $SkipBuild) {
foreach ($Build in $WindowsSDKBuilds) {
Invoke-BuildStep Build-ExperimentalSDK $Build

Get-ChildItem "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift\windows\$($Build.Architecture.LLVMName)\" | Out-Null
}

Get-ChildItem "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows" -Filter "*.lib" -File -ErrorAction Ignore | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Windows -Identifier WindowsExperimental)\usr\lib\swift_static\windows\$($Build.Architecture.LLVMName)\" | Out-Null
Expand Down Expand Up @@ -3794,6 +3904,11 @@ if (-not $SkipBuild) {
foreach ($Build in $AndroidSDKBuilds) {
Invoke-BuildStep Build-ExperimentalSDK $Build

Get-ChildItem "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift\android\$($Build.Architecture.LLVMName)\" | Out-Null
}

Get-ChildItem "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift_static\android" -File | Where-Object { $_.Name -match ".a$|.so$" } | ForEach-Object {
Write-Host -BackgroundColor DarkRed -ForegroundColor White "$($_.FullName) is not nested in an architecture directory"
Move-Item $_.FullName "$(Get-SwiftSDK Android -Identifier AndroidExperimental)\usr\lib\swift_static\android\$($Build.Architecture.LLVMName)\" | Out-Null
Expand Down