Skip to content

Commit a9ff164

Browse files
committed
Update mimalloc to v3.0.1 and enable mimalloc for win/arm64
1 parent 1cb3416 commit a9ff164

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ jobs:
234234
tee -a "${GITHUB_OUTPUT}" <<-EOF
235235
indexstore_db_revision=refs/tags/${{ inputs.swift_tag }}
236236
llvm_project_revision=refs/tags/${{ inputs.swift_tag }}
237-
mimalloc_revision=refs/tags/v2.1.7
237+
mimalloc_revision=refs/tags/v3.0.1
238238
sourcekit_lsp_revision=refs/tags/${{ inputs.swift_tag }}
239239
swift_revision=refs/tags/${{ inputs.swift_tag }}
240240
swift_argument_parser_revision=refs/tags/1.4.0

.github/workflows/swift-toolchain.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3430,22 +3430,29 @@ jobs:
34303430
}
34313431
34323432
- uses: actions/checkout@v4
3433-
if: matrix.arch == 'amd64'
34343433
with:
34353434
repository: microsoft/mimalloc
34363435
ref: ${{ inputs.mimalloc_revision }}
34373436
path: ${{ github.workspace }}/SourceCache/mimalloc
34383437

34393438
- name: Build and apply mimalloc
3440-
if: matrix.arch == 'amd64'
34413439
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 { "" }
34423443
# 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
34443445
$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" `
34463447
-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" `
34483449
-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+
}
34493456
$MimallocExecutables = @("swift.exe",
34503457
"swiftc.exe",
34513458
"swift-driver.exe",
@@ -3459,21 +3466,25 @@ jobs:
34593466
"ld64.lld.exe")
34603467
foreach ($Exe in $MimallocExecutables) {
34613468
# 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"
34633470
# 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"
34653472
}
34663473
34673474
- name: Package Build Tools
34683475
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" }
34693479
msbuild -nologo -restore -maxCpuCount `
34703480
-p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ `
34713481
-p:Configuration=Release `
34723482
-p:SignOutput=${{ inputs.signed }} `
34733483
-p:CERTIFICATE=${env:CERTIFICATE} `
34743484
-p:PASSPHRASE=${{ secrets.PASSPHRASE }} `
34753485
-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 `
34773488
-p:ProductArchitecture=${{ matrix.arch }} `
34783489
-p:ProductVersion=${{ inputs.swift_version }} `
34793490
${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bld/bld.wixproj

default.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
<project remote="github" name="madler/zlib" path="zlib" revision="refs/tags/v1.3.1" />
6565

66-
<project remote="github" name="microsoft/mimalloc" path="mimalloc" revision="refs/tags/v2.1.7" />
66+
<project remote="github" name="microsoft/mimalloc" path="mimalloc" revision="refs/tags/v3.0.1" />
6767

6868
<project remote="github" name="ninja-build/ninja" path="ninja" groups="notdefault,dependencies" revision="master" />
6969
</manifest>

0 commit comments

Comments
 (0)