@@ -3402,22 +3402,29 @@ jobs:
3402
3402
}
3403
3403
3404
3404
- uses : actions/checkout@v4
3405
- if : matrix.arch == 'amd64'
3406
3405
with :
3407
3406
repository : microsoft/mimalloc
3408
3407
ref : ${{ inputs.mimalloc_revision }}
3409
3408
path : ${{ github.workspace }}/SourceCache/mimalloc
3410
3409
3411
3410
- name : Build and apply mimalloc
3412
- if : matrix.arch == 'amd64'
3413
3411
run : |
3412
+ $HostMSArch = if ("${{ matrix.arch }}" -eq "arm64") { "arm64" } else { "x64" }
3413
+ $HostSuffix = if ("${{ matrix.arch }}" -eq "arm64") { "-arm64" } else { "" }
3414
+ $BuildSuffix = if ("${{ inputs.build_arch }}" -eq "arm64") { "-arm64" } else { "" }
3414
3415
# Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject
3415
- msbuild ${{ github.workspace }}\SourceCache\mimalloc\ide\vs2022\mimalloc.sln -p:Configuration=Release
3416
+ msbuild ${{ github.workspace }}\SourceCache\mimalloc\ide\vs2022\mimalloc.sln -p:Configuration=Release -p:Platform=$HostMSArch
3416
3417
$ToolchainBin = "${{ github.workspace }}\BuildRoot\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin"
3417
- Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-x64 \Release\mimalloc-override .dll" `
3418
+ Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch \Release\mimalloc.dll" `
3418
3419
-Destination "$ToolchainBin"
3419
- Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-x64 \Release\mimalloc-redirect.dll" `
3420
+ Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch \Release\mimalloc-redirect$HostSuffix .dll" `
3420
3421
-Destination "$ToolchainBin"
3422
+ # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3423
+ # https://github.com/microsoft/mimalloc/issues/997
3424
+ if ("${{ inputs.build_arch }}" -ne "${{ matrix.arch }}") {
3425
+ Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch\Release\mimalloc-redirect$HostSuffix.dll" `
3426
+ -Destination "$ToolchainBin/mimalloc-redirect$BuildSuffix.dll"
3427
+ }
3421
3428
$MimallocExecutables = @("swift.exe",
3422
3429
"swiftc.exe",
3423
3430
"swift-driver.exe",
@@ -3431,21 +3438,25 @@ jobs:
3431
3438
"ld64.lld.exe")
3432
3439
foreach ($Exe in $MimallocExecutables) {
3433
3440
# Binary-patch in place
3434
- ${{ github.workspace }}\SourceCache\mimalloc\bin\minject -f -i -v "$ToolchainBin\$Exe"
3441
+ & " ${{ github.workspace }}\SourceCache\mimalloc\bin\minject$BuildSuffix" -f -i -v "$ToolchainBin\$Exe"
3435
3442
# Log the import table
3436
- ${{ github.workspace }}\SourceCache\mimalloc\bin\minject -l "$ToolchainBin\$Exe"
3443
+ & " ${{ github.workspace }}\SourceCache\mimalloc\bin\minject$BuildSuffix" -l "$ToolchainBin\$Exe"
3437
3444
}
3438
3445
3439
3446
- name : Package Build Tools
3440
3447
run : |
3448
+ # When cross-compiling, bundle the second mimalloc redirect dll as a workaround for
3449
+ # https://github.com/microsoft/mimalloc/issues/997
3450
+ $WORKAROUND_MIMALLOC_ISSUE_997 = if ("${{ inputs.build_arch }}" -ne "${{ matrix.arch }}") { "true" } else { "false" }
3441
3451
msbuild -nologo -restore -maxCpuCount `
3442
3452
-p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ `
3443
3453
-p:Configuration=Release `
3444
3454
-p:SignOutput=${{ inputs.signed }} `
3445
3455
-p:CERTIFICATE=${env:CERTIFICATE} `
3446
3456
-p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
3447
3457
-p:TOOLCHAIN_ROOT=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain `
3448
- -p:ENABLE_MIMALLOC=${{ matrix.arch == 'amd64' && 'true' || 'false' }} `
3458
+ -p:ENABLE_MIMALLOC=true `
3459
+ -p:WORKAROUND_MIMALLOC_ISSUE_997=$WORKAROUND_MIMALLOC_ISSUE_997 `
3449
3460
-p:ProductArchitecture=${{ matrix.arch }} `
3450
3461
-p:ProductVersion=${{ inputs.swift_version }} `
3451
3462
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bld/bld.wixproj
0 commit comments