Skip to content

Commit 699e68e

Browse files
authored
Update mimalloc to v3.0.1 and enable mimalloc for win/arm64 (#886)
1 parent 523d97e commit 699e68e

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
@@ -233,7 +233,7 @@ jobs:
233233
tee -a "${GITHUB_OUTPUT}" <<-EOF
234234
indexstore_db_revision=refs/tags/${{ inputs.swift_tag }}
235235
llvm_project_revision=refs/tags/${{ inputs.swift_tag }}
236-
mimalloc_revision=refs/tags/v2.1.7
236+
mimalloc_revision=refs/tags/v3.0.1
237237
sourcekit_lsp_revision=refs/tags/${{ inputs.swift_tag }}
238238
swift_revision=refs/tags/${{ inputs.swift_tag }}
239239
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
@@ -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

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)