Skip to content

Commit 4f246dd

Browse files
committed
build.ps1: add CDispatch build
Introduce a new build product: `CDispatch`. This is a dynamic variant of libdispatch and BlocksRuntime. This breaks the cycle of the Swift runtime and dispatch. This should also allow us to simplify the toolchain build.
1 parent 9d7d3a1 commit 4f246dd

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

utils/build.ps1

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ enum Project {
696696
BuildTools
697697
RegsGen2
698698

699+
CDispatch
699700
Compilers
700701
FoundationMacros
701702
TestingMacros
@@ -1940,6 +1941,20 @@ function Load-LitTestOverrides($Filename) {
19401941
}
19411942
}
19421943

1944+
function Build-CDispatch([Hashtable] $Platform, [switch] $Static = $false) {
1945+
Build-CMakeProject `
1946+
-Src $SourceCache\swift-corelibs-libdispatch `
1947+
-Bin (Get-ProjectBinaryCache $Platform CDispatch) `
1948+
-BuildTargets default `
1949+
-Platform $Platform `
1950+
-UsePinnedCompilers C,CXX `
1951+
-Defines @{
1952+
BUILD_SHARED_LIBS = "YES";
1953+
BUILD_TESTING = "NO";
1954+
ENABLE_SWIFT = "NO";
1955+
}
1956+
}
1957+
19431958
function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch] $Test) {
19441959
$BuildTools = [IO.Path]::Combine((Get-ProjectBinaryCache $BuildPlatform BuildTools), "bin")
19451960
$PythonRoot = [IO.Path]::Combine((Get-PythonPath $Platform), "tools")
@@ -2550,17 +2565,11 @@ function Build-ExperimentalRuntime([Hashtable] $Platform, [switch] $Static = $fa
25502565
-UseGNUDriver `
25512566
-Defines @{
25522567
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
2553-
# TODO(compnerd) enforce dynamic linking of BlocksRuntime and dispatch.
2554-
CMAKE_CXX_FLAGS = $(if ($Static) { @("-Ddispatch_STATIC") } else { @() });
2555-
CMAKE_Swift_FLAGS = $(if ($Static) { @("-Xcc", "-static-libclosure") } else { @() });
25562568
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
25572569

2558-
# NOTE(compnerd) we can get away with this currently because we only
2559-
# use the C portion of the dispatch build, which is supposed to always
2560-
# be built dynamically. Currently, we do not do this due to limitations
2561-
# of the build system, but because we are building statically, we do
2562-
# not link against the runtime and can get away with it.
2563-
dispatch_DIR = (Get-ProjectCMakeModules $Platform Dispatch);
2570+
dispatch_DIR = (Get-ProjectCMakeModules $Platform CDispatch);
2571+
2572+
# FIXME(compnerd) remove this once the default option is flipped to `ON`.
25642573
SwiftCore_ENABLE_CONCURRENCY = "YES";
25652574
}
25662575

@@ -3005,6 +3014,8 @@ function Build-SDK([Hashtable] $Platform, [switch] $IncludeMacros = $false) {
30053014
}
30063015

30073016
function Build-ExperimentalSDK([Hashtable] $Platform) {
3017+
Invoke-BuildStep Build-CDispatch $Platform
3018+
30083019
# TODO(compnerd) we currently build the experimental SDK with just the static
30093020
# variant. We should aim to build both dynamic and static variants.
30103021
Invoke-BuildStep Build-ExperimentalRuntime $Platform -Static
@@ -3712,6 +3723,7 @@ if (-not $SkipBuild) {
37123723

37133724
Invoke-BuildStep Build-CMark $HostPlatform
37143725
Invoke-BuildStep Build-XML2 $HostPlatform
3726+
Invoke-BuildStep Build-CDispatch $HostPlatform
37153727
Invoke-BuildStep Build-Compilers $HostPlatform -Variant "Asserts"
37163728

37173729
Invoke-BuildStep Build-SDK $BuildPlatform -IncludeMacros

0 commit comments

Comments
 (0)