@@ -3430,22 +3430,29 @@ jobs:
3430
3430
}
3431
3431
3432
3432
- uses : actions/checkout@v4
3433
- if : matrix.arch == 'amd64'
3434
3433
with :
3435
3434
repository : microsoft/mimalloc
3436
3435
ref : ${{ inputs.mimalloc_revision }}
3437
3436
path : ${{ github.workspace }}/SourceCache/mimalloc
3438
3437
3439
3438
- name : Build and apply mimalloc
3440
- if : matrix.arch == 'amd64'
3441
3439
run : |
3440
+ $HostMSArch = if ("${{ matrix.arch }}" -eq "arm64") { "arm64" } else { "x64" }
3441
+ $HostSuffix = if ("${{ matrix.arch }}" -eq "arm64") { "-arm64" } else { "" }
3442
+ $BuildSuffix = if ("${{ inputs.build_arch }}" -eq "arm64") { "-arm64" } else { "" }
3442
3443
# Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject
3443
- msbuild ${{ github.workspace }}\SourceCache\mimalloc\ide\vs2022\mimalloc.sln -p:Configuration=Release
3444
+ msbuild ${{ github.workspace }}\SourceCache\mimalloc\ide\vs2022\mimalloc.sln -p:Configuration=Release -p:Platform=$HostMSArch
3444
3445
$ToolchainBin = "${{ github.workspace }}\BuildRoot\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
3445
- Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-x64 \Release\mimalloc-override .dll" `
3446
+ Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch \Release\mimalloc.dll" `
3446
3447
-Destination "$ToolchainBin"
3447
- Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-x64 \Release\mimalloc-redirect.dll" `
3448
+ Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch \Release\mimalloc-redirect$HostSuffix .dll" `
3448
3449
-Destination "$ToolchainBin"
3450
+ # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3451
+ # https://github.com/microsoft/mimalloc/issues/997
3452
+ if ("${{ inputs.build_arch }}" -ne "${{ matrix.arch }}") {
3453
+ Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch\Release\mimalloc-redirect$HostSuffix.dll" `
3454
+ -Destination "$ToolchainBin/mimalloc-redirect$BuildSuffix.dll"
3455
+ }
3449
3456
$MimallocExecutables = @("swift.exe",
3450
3457
"swiftc.exe",
3451
3458
"swift-driver.exe",
@@ -3459,21 +3466,25 @@ jobs:
3459
3466
"ld64.lld.exe")
3460
3467
foreach ($Exe in $MimallocExecutables) {
3461
3468
# Binary-patch in place
3462
- ${{ github.workspace }}\SourceCache\mimalloc\bin\minject -f -i -v "$ToolchainBin\$Exe"
3469
+ & " ${{ github.workspace }}\SourceCache\mimalloc\bin\minject$BuildSuffix" -f -i -v "$ToolchainBin\$Exe"
3463
3470
# Log the import table
3464
- ${{ github.workspace }}\SourceCache\mimalloc\bin\minject -l "$ToolchainBin\$Exe"
3471
+ & " ${{ github.workspace }}\SourceCache\mimalloc\bin\minject$BuildSuffix" -l "$ToolchainBin\$Exe"
3465
3472
}
3466
3473
3467
3474
- name : Package Build Tools
3468
3475
run : |
3476
+ # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3477
+ # https://github.com/microsoft/mimalloc/issues/997
3478
+ $WORKAROUND_MIMALLOC_ISSUE_997 = if ("${{ inputs.build_arch }}" -ne "${{ matrix.arch }}") { "true" } else { "false" }
3469
3479
msbuild -nologo -restore -maxCpuCount `
3470
3480
-p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ `
3471
3481
-p:Configuration=Release `
3472
3482
-p:SignOutput=${{ inputs.signed }} `
3473
3483
-p:CERTIFICATE=${env:CERTIFICATE} `
3474
3484
-p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
3475
3485
-p:TOOLCHAIN_ROOT=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain `
3476
- -p:ENABLE_MIMALLOC=${{ matrix.arch == 'amd64' && 'true' || 'false' }} `
3486
+ -p:ENABLE_MIMALLOC=true `
3487
+ -p:WORKAROUND_MIMALLOC_ISSUE_997=$WORKAROUND_MIMALLOC_ISSUE_997 `
3477
3488
-p:ProductArchitecture=${{ matrix.arch }} `
3478
3489
-p:ProductVersion=${{ inputs.swift_version }} `
3479
3490
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bld/bld.wixproj
0 commit comments