@@ -3402,22 +3402,29 @@ jobs:
34023402 }
34033403
34043404 - uses : actions/checkout@v4
3405- if : matrix.arch == 'amd64'
34063405 with :
34073406 repository : microsoft/mimalloc
34083407 ref : ${{ inputs.mimalloc_revision }}
34093408 path : ${{ github.workspace }}/SourceCache/mimalloc
34103409
34113410 - name : Build and apply mimalloc
3412- if : matrix.arch == 'amd64'
34133411 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 { "" }
34143415 # 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
34163417 $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" `
34183419 -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" `
34203421 -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+ }
34213428 $MimallocExecutables = @("swift.exe",
34223429 "swiftc.exe",
34233430 "swift-driver.exe",
@@ -3431,21 +3438,25 @@ jobs:
34313438 "ld64.lld.exe")
34323439 foreach ($Exe in $MimallocExecutables) {
34333440 # 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"
34353442 # 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"
34373444 }
34383445
34393446 - name : Package Build Tools
34403447 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" }
34413451 msbuild -nologo -restore -maxCpuCount `
34423452 -p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ `
34433453 -p:Configuration=Release `
34443454 -p:SignOutput=${{ inputs.signed }} `
34453455 -p:CERTIFICATE=${env:CERTIFICATE} `
34463456 -p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
34473457 -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 `
34493460 -p:ProductArchitecture=${{ matrix.arch }} `
34503461 -p:ProductVersion=${{ inputs.swift_version }} `
34513462 ${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bld/bld.wixproj
0 commit comments