Skip to content

Commit fcb81f9

Browse files
committed
Work around the LNK1322 issue in swift-build on windows
#79740
1 parent a172489 commit fcb81f9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

utils/build.ps1

+6-3
Original file line numberDiff line numberDiff line change
@@ -2539,6 +2539,10 @@ function Build-System($Arch) {
25392539
}
25402540

25412541
function Build-Build($Arch) {
2542+
# Use lld to workaround the ARM64 LNK1322 issue: https://github.com/swiftlang/swift/issues/79740
2543+
# FIXME(hjyamauchi) Have a real fix
2544+
$ArchSpecificOptions = if ($Arch -eq $ArchARM64) { @{ CMAKE_Swift_FLAGS = "-use-ld=lld-link"; } } else { @{} }
2545+
25422546
Build-CMakeProject `
25432547
-Src $SourceCache\swift-build `
25442548
-Bin (Get-HostProjectBinaryCache Build) `
@@ -2547,7 +2551,7 @@ function Build-Build($Arch) {
25472551
-Platform Windows `
25482552
-UseBuiltCompilers C,CXX,Swift `
25492553
-SwiftSDK (Get-SwiftSDK Windows) `
2550-
-Defines @{
2554+
-Defines (@{
25512555
BUILD_SHARED_LIBS = "YES";
25522556
CMAKE_STATIC_LIBRARY_PREFIX_Swift = "lib";
25532557
ArgumentParser_DIR = (Get-HostProjectCMakeModules ArgumentParser);
@@ -2557,7 +2561,7 @@ function Build-Build($Arch) {
25572561
TSC_DIR = (Get-HostProjectCMakeModules ToolsSupportCore);
25582562
SQLite3_INCLUDE_DIR = "$LibraryRoot\sqlite-3.46.0\usr\include";
25592563
SQLite3_LIBRARY = "$LibraryRoot\sqlite-3.46.0\usr\lib\SQLite3.lib";
2560-
}
2564+
} + $ArchSpecificOptions)
25612565
}
25622566

25632567
function Build-ToolsSupportCore($Arch) {
@@ -3172,7 +3176,6 @@ if ($Clean) {
31723176
}
31733177
}
31743178

3175-
31763179
if (-not $SkipBuild) {
31773180
if ($EnableCaching -And (-Not (Test-SCCacheAtLeast -Major 0 -Minor 7 -Patch 4))) {
31783181
throw "Minimum required sccache version is 0.7.4"

0 commit comments

Comments
 (0)