Skip to content

Commit 8331434

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 1e403ec commit 8331434

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

utils/build.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2481,10 +2481,25 @@ 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+
24842499
Build-CMakeProject `
24852500
-Src $SourceCache\swift-corelibs-foundation `
24862501
-Bin $FoundationBinaryCache `
2487-
-InstallTo $(if ($Static) { "$(Get-SwiftSDK $Platform.OS -Identifier "$($Platform.OS)Experimental")\usr" } else { "$(Get-SwiftSDK $Platform.OS)\usr" }) `
2502+
-InstallTo $InstallRoot `
24882503
-Platform $Platform `
24892504
-UseBuiltCompilers ASM,C,CXX,Swift `
24902505
-SwiftSDK (Get-SwiftSDK $Platform.OS) `
@@ -2493,6 +2508,7 @@ function Build-Foundation {
24932508
CMAKE_FIND_PACKAGE_PREFER_CONFIG = "YES";
24942509
CMAKE_NINJA_FORCE_RESPONSE_FILE = "YES";
24952510
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
2511+
CMAKE_Swift_FLAGS = $SwiftFlags;
24962512
ENABLE_TESTING = "NO";
24972513
FOUNDATION_BUILD_TOOLS = if ($Platform.OS -eq [OS]::Windows) { "YES" } else { "NO" };
24982514
CURL_DIR = "$BinaryCache\$($Platform.Triple)\usr\lib\cmake\CURL";

0 commit comments

Comments
 (0)