Skip to content

Commit 3b82b4b

Browse files
committed
Fix mimalloc patching
1 parent d8a1649 commit 3b82b4b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

utils/build.ps1

+21-5
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ if ($PinnedBuild -eq "") {
191191
$PinnedVersion = "6.0.3"
192192
}
193193
"ARM64" {
194-
$PinnedBuild = "https://download.swift.org/swift-6.0.3-release/windows10-arm64/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-windows10-arm64.exe"
194+
$PinnedBuild = "https://download.swift.org/installer-arm64.exe"
195195
$PinnedSHA256 = "81474651E59A9955C9E6A389EF53ABD61631FFC62C63A2A02977271019E7C722"
196-
$PinnedVersion = "6.0.3"
196+
$PinnedVersion = "6.0.0"
197197
}
198198
default { throw "Unsupported processor architecture" }
199199
}
@@ -557,6 +557,7 @@ function Invoke-Program() {
557557
[string] $Executable,
558558
[switch] $OutNull = $false,
559559
[string] $OutFile = "",
560+
[string] $ErrorFile = "",
560561
[Parameter(Position = 1, ValueFromRemainingArguments)]
561562
[string[]] $Args
562563
)
@@ -588,13 +589,20 @@ function Invoke-Program() {
588589
} elseif ("" -ne $OutFile) {
589590
$OutputLine += " > `"$OutFile`""
590591
}
592+
if ("" -ne $ErrorFile) {
593+
$OutputLine += " > `"$ErrorFile`""
594+
}
591595

592596
Write-Output $OutputLine
593597
} else {
594598
if ($OutNull) {
595599
& $Executable @Args | Out-Null
600+
} elseif ("" -ne $OutFile -and "" -ne $ErrorFile) {
601+
& $Executable @Args > $OutFile 2> $ErrorFile
596602
} elseif ("" -ne $OutFile) {
597-
& $Executable @Args | Out-File -Encoding UTF8 $OutFile
603+
& $Executable @Args > $OutFile
604+
} elseif ("" -ne $ErrorFile) {
605+
& $Executable @Args 2> $ErrorFile
598606
} else {
599607
& $Executable @Args
600608
}
@@ -1811,9 +1819,17 @@ function Build-mimalloc() {
18111819
foreach ($Tool in $Tools) {
18121820
$Binary = [IO.Path]::Combine($Arch.ToolchainInstallRoot, "usr", "bin", $Tool)
18131821
# Binary-patch in place
1814-
Start-Process -Wait -WindowStyle Hidden -FilePath "$SourceCache\mimalloc\bin\minject$BuildSuffix" -ArgumentList @("-f", "-i", "-v", "$Binary")
1822+
Invoke-Program "$SourceCache\mimalloc\bin\minject$BuildSuffix" "-f" "-i" "-v" "$Binary"
18151823
# Log the import table
1816-
Start-Process -Wait -WindowStyle Hidden -FilePath "$SourceCache\mimalloc\bin\minject$BuildSuffix" -ArgumentList @("-l", "$Binary")
1824+
$LogFile = "$BinaryCache\$($Arch.LLVMTarget)\mimalloc\minject-log-$Tool.txt"
1825+
$ErrorFile = "$BinaryCache\$($Arch.LLVMTarget)\mimalloc\minject-log-$Tool-error.txt"
1826+
Invoke-Program "$SourceCache\mimalloc\bin\minject$BuildSuffix" "-l" "$Binary" -OutFile $LogFile 2> $ErrorFile
1827+
# Verify patching
1828+
$Found = Select-String -Path $LogFile -Pattern "mimalloc"
1829+
if (-not $Found) {
1830+
Get-Content $ErrorFile
1831+
throw "Failed to patch mimalloc for $Tool"
1832+
}
18171833
}
18181834
}
18191835

0 commit comments

Comments
 (0)