Skip to content

Commit 4a3899f

Browse files
committed
utils: adjust the Swift flags for building Foundation
Ensure that we properly configure Foundation for building statically. We would previously build against a dynamic variant of the standard library and libclosure. The new flags correct this so that we correctly load the appropriate libraries.
1 parent ddca2ba commit 4a3899f

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

utils/build.ps1

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,18 +2481,40 @@ function Build-Foundation {
24812481
Get-ProjectBinaryCache $Platform DynamicFoundation
24822482
}
24832483

2484+
$InstallRoot = if ($Static) {
2485+
"$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr"
2486+
} else {
2487+
"$(Get-SwiftSDK $Platform.OS)\usr"
2488+
}
2489+
2490+
$SwiftFlags = if ($Static) {
2491+
# FIXME(compnerd) use `-Xfrontend -use-static-resource-dir` to workaround merge module job failure
2492+
# FIXME(compnerd) use `-Xcc -DSWIFT_STATIC_STDLIB` to workaround ClangImporter setup limitation
2493+
# FIXME(compnerd) we do not pass `-Xcc -static-libclosure` as we do nto build aganst a static libdispatch yet
2494+
@("-static-stdlib", "-Xfrontend", "-use-static-resource-dir", "-Xcc", "-DSWIFT_STATIC_STDLIB")
2495+
} else {
2496+
@()
2497+
}
2498+
2499+
$SwiftSDK = if ($Static) {
2500+
Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS.ToString())Experimental"
2501+
} else {
2502+
Get-SwiftSDK $Platform.OS
2503+
}
2504+
24842505
Build-CMakeProject `
24852506
-Src $SourceCache\swift-corelibs-foundation `
24862507
-Bin $FoundationBinaryCache `
2487-
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" } else { "$(Get-SwiftSDK $Platform.OS)\usr" }) `
2508+
-InstallTo $InstallRoot `
24882509
-Platform $Platform `
24892510
-UseBuiltCompilers ASM,C,CXX,Swift `
2490-
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
2511+
-SwiftSDK $SwiftSDK `
24912512
-Defines @{
24922513
BUILD_SHARED_LIBS = if ($Static) { "NO" } else { "YES" };
24932514
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
24942515
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
24952516
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2517+
CMAKE_Swift_FLAGS = $SwiftFlags;
24962518
ENABLE_TESTING = "NO";
24972519
FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS]::Windows) { "YES" } else { "NO" };
24982520
CURL_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\CURL";

0 commit comments

Comments
 (0)