Skip to content

Commit ef7c5e2

Browse files
committed
utils: build early swift-driver on Windows
This prepares the swift-driver building on Windows. By statically linking the runtime and its dependencies, this will allow us to avoid the runtime shuffling that is required to get the runtime required to get the swift-driver working.
1 parent b849524 commit ef7c5e2

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

utils/build.ps1

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,7 @@ function Invoke-BuildStep {
674674
enum Project {
675675
BuildTools
676676
RegsGen2
677+
EarlySwiftDriver
677678

678679
Compilers
679680
FoundationMacros
@@ -1203,10 +1204,10 @@ function Get-PinnedToolchainToolsDir() {
12031204
"unknown-Asserts-development.xctoolchain", "usr", "bin")
12041205
}
12051206

1206-
function Get-PinnedToolchainSDK() {
1207+
function Get-PinnedToolchainSDK([OS] $OS = $BuildPlatform.OS, [string] $Identifier = $OS.ToString()) {
12071208
return [IO.Path]::Combine("$BinaryCache\", "toolchains", $PinnedToolchain,
12081209
"LocalApp", "Programs", "Swift", "Platforms", (Get-PinnedToolchainVersion),
1209-
"Windows.platform", "Developer", "SDKs", "Windows.sdk")
1210+
"$($OS.ToString()).platform", "Developer", "SDKs", "$Identifier.sdk")
12101211
}
12111212

12121213
function Get-PinnedToolchainRuntime() {
@@ -1469,7 +1470,7 @@ function Build-CMakeProject {
14691470

14701471
} else {
14711472
Add-KeyValueIfNew $Defines CMAKE_Swift_COMPILER_TARGET $Platform.Triple
1472-
$SwiftArgs += @("-sdk", (Get-PinnedToolchainSDK))
1473+
$SwiftArgs += @("-sdk", $(if ($SwiftSDK) { $SwiftSDK } else { Get-PinnedToolchainSDK }))
14731474
}
14741475

14751476
# Debug Information
@@ -1754,6 +1755,26 @@ function Build-BuildTools([Hashtable] $Platform) {
17541755
}
17551756
}
17561757

1758+
function Build-EarlySwiftDriver {
1759+
Build-CMakeProject `
1760+
-Src $SourceCache\swift-driver `
1761+
-Bin (Get-ProjectBinaryCache $Platform EarlySwiftDriver) `
1762+
-Platform $BuildPlatform `
1763+
-UsePinnedCompilers C,CXX,Swift `
1764+
-SwiftSDK (Get-PinnedToolchainSDK -OS $BuildPlatform.OS -Identifier "$($BuildPlatform.OS)Experimental") `
1765+
-BuildTargets default `
1766+
-Defines @{
1767+
BUILD_SHARED_LIBS = "NO";
1768+
BUILD_TESTING = "NO";
1769+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
1770+
# TODO(compnerd) - enforce dynamic BlocksRuntime and dispatch
1771+
CMAKE_Swift_FLAGS = @("-static-stdlib", "-Xfrontend", "-use-static-resource-dir", "-Xcc", "-static-libclosure", "-Xcc", "-Ddispatch_STATIC");
1772+
SWIFT_DRIVER_BUILD_TOOLS = "NO";
1773+
SQLite3_INCLUDE_DIR = "$SourceCache\swift-toolchain-sqlite\Sources\CSQLite\include";
1774+
SQLite3_LIBRARY = "$(Get-ProjectBinaryCache $Platform SQLite)\SQLite3.lib";
1775+
}
1776+
}
1777+
17571778
function Write-PList {
17581779
[CmdletBinding(PositionalBinding = $false)]
17591780
param
@@ -1823,6 +1844,7 @@ function Get-CompilersDefines([Hashtable] $Platform, [string] $Variant, [switch]
18231844
CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe");
18241845
CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe");
18251846
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
1847+
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
18261848
CMAKE_Swift_FLAGS = $SwiftFlags;
18271849
LibXml2_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\libxml2-2.11.5";
18281850
LLDB_LIBXML2_VERSION = "2.11.5";
@@ -3429,6 +3451,8 @@ if (-not $SkipBuild) {
34293451

34303452
Invoke-BuildStep Build-CMark $BuildPlatform
34313453
Invoke-BuildStep Build-BuildTools $BuildPlatform
3454+
Invoke-BuildStep Build-SQLite $BuildPlatform
3455+
Invoke-BuildStep Build-EarlySwiftDriver $BuildPlatform
34323456
if ($IsCrossCompiling) {
34333457
Invoke-BuildStep Build-XML2 $BuildPlatform
34343458
Invoke-BuildStep Build-Compilers $BuildPlatform -Variant "Asserts"

0 commit comments

Comments
 (0)