diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index 04211da6..948ee1cd 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -227,14 +227,14 @@ jobs: branch_name="release/$branch_version_string" fi - repo init --quiet --groups default --depth 1 -u https://github.com/compnerd/swift-build -b $branch_name + repo init --quiet --groups default --depth 1 -u https://github.com/thebrowsercompany/swift-build -b hiroshi/mimallocarm64 repo sync --quiet --no-clone-bundle --no-tags --jobs $(nproc --all) if [[ "${{ inputs.swift_tag }}" != "" ]] ; then tee -a "${GITHUB_OUTPUT}" <<-EOF indexstore_db_revision=refs/tags/${{ inputs.swift_tag }} llvm_project_revision=refs/tags/${{ inputs.swift_tag }} - mimalloc_revision=refs/tags/v2.1.7 + mimalloc_revision=refs/tags/v3.0.1 sourcekit_lsp_revision=refs/tags/${{ inputs.swift_tag }} swift_revision=refs/tags/${{ inputs.swift_tag }} swift_argument_parser_revision=refs/tags/1.4.0 diff --git a/.github/workflows/swift-toolchain.yml b/.github/workflows/swift-toolchain.yml index b06e4db7..e0098255 100644 --- a/.github/workflows/swift-toolchain.yml +++ b/.github/workflows/swift-toolchain.yml @@ -3430,22 +3430,31 @@ jobs: } - uses: actions/checkout@v4 - if: matrix.arch == 'amd64' with: repository: microsoft/mimalloc ref: ${{ inputs.mimalloc_revision }} path: ${{ github.workspace }}/SourceCache/mimalloc - name: Build and apply mimalloc - if: matrix.arch == 'amd64' run: | + $HostMSArch = if ("${{ matrix.arch }}" -eq "amd64") { "x64" } else { "arm64" } + $HostSuffix = if ("${{ matrix.arch }}" -eq "amd64") { "" } else { "-arm64" } + $BuildSuffix = if ("${{ inputs.build_arch }}" -eq "amd64") { "" } else { "-arm64" } # Reference: https://github.com/microsoft/mimalloc/tree/dev/bin#minject - msbuild ${{ github.workspace }}\SourceCache\mimalloc\ide\vs2022\mimalloc.sln -p:Configuration=Release + msbuild ${{ github.workspace }}\SourceCache\mimalloc\ide\vs2022\mimalloc.sln -p:Configuration=Release -p:Platform=$HostMSArch $ToolchainBin = "${{ github.workspace }}\BuildRoot\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin" - Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-x64\Release\mimalloc-override.dll" ` - -Destination "$ToolchainBin" - Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-x64\Release\mimalloc-redirect.dll" ` + Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch\Release\mimalloc.dll" ` -Destination "$ToolchainBin" + # We always use the file name "mimalloc-redirect.dll" at the + # destination even on arm64. Copy and rename as such. This + # is because the arm64 minject, which would use the "-arm64" + # suffix name, won't run on win/x64 but the x64 minject, + # which uses the unsuffixed name, runs both on x64 and arm64 + # in the cross-compile build. + Copy-Item -Path "${{ github.workspace }}\SourceCache\mimalloc\out\msvc-$HostMSArch\Release\mimalloc-redirect$HostSuffix.dll" ` + -Destination "$ToolchainBin/mimalloc-redirect$BuildSuffix.dll" + #-Destination "$ToolchainBin" + #-Destination "$ToolchainBin/mimalloc-redirect.dll" $MimallocExecutables = @("swift.exe", "swiftc.exe", "swift-driver.exe", @@ -3458,14 +3467,16 @@ jobs: "ld.lld.exe", "ld64.lld.exe") foreach ($Exe in $MimallocExecutables) { - # Binary-patch in place - ${{ github.workspace }}\SourceCache\mimalloc\bin\minject -f -i -v "$ToolchainBin\$Exe" + # Binary-patch in place. This always uses the x64 minject even on + # win/arm64 via emulation for the above reason. + & "${{ github.workspace }}\SourceCache\mimalloc\bin\minject$BuildSuffix" -f -i -v "$ToolchainBin\$Exe" # Log the import table - ${{ github.workspace }}\SourceCache\mimalloc\bin\minject -l "$ToolchainBin\$Exe" + & "${{ github.workspace }}\SourceCache\mimalloc\bin\minject$BuildSuffix" -l "$ToolchainBin\$Exe" } - name: Package Build Tools run: | + $MIMALLOC_REDIRECT_SUFFIX = = if ("${{ inputs.build_arch }}" -eq "amd64") { "" } else { "-arm64" } msbuild -nologo -restore -maxCpuCount ` -p:BaseOutputPath=${{ github.workspace }}\BinaryCache\installer\ ` -p:Configuration=Release ` @@ -3473,7 +3484,8 @@ jobs: -p:CERTIFICATE=${env:CERTIFICATE} ` -p:PASSPHRASE=${{ secrets.PASSPHRASE }} ` -p:TOOLCHAIN_ROOT=${{ github.workspace }}/BuildRoot/Library/Developer/Toolchains/unknown-Asserts-development.xctoolchain ` - -p:ENABLE_MIMALLOC=${{ matrix.arch == 'amd64' && 'true' || 'false' }} ` + -p:ENABLE_MIMALLOC=true ` + -p:MIMALLOC_REDIRECT_SUFFIX=$MIMALLOC_REDIRECT_SUFFIX ` -p:ProductArchitecture=${{ matrix.arch }} ` -p:ProductVersion=${{ inputs.swift_version }} ` ${{ github.workspace }}/SourceCache/swift-installer-scripts/platforms/Windows/bld/bld.wixproj diff --git a/default.xml b/default.xml index 44ce0437..2376f51e 100644 --- a/default.xml +++ b/default.xml @@ -30,7 +30,7 @@ - + @@ -63,7 +63,7 @@ - +