Skip to content

Commit a8e13c3

Browse files
committed
GHA: setup a separate step for mimalloc
Extract the mimalloc build as that can run in parallel with other jobs.
1 parent 699e68e commit a8e13c3

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/swift-toolchain.yml

+76
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,82 @@ jobs:
520520
name: ds2-${{ matrix.os }}-${{ matrix.arch }}
521521
path: ${{ github.workspace }}/BinaryCache/Library/Developer
522522

523+
mimalloc:
524+
if: ${{ inputs.build_os == 'Windows' }}
525+
runs-on: ${{ inputs.default_build_runner }}
526+
527+
strategy:
528+
fail-fast: false
529+
matrix: ${{ fromJSON(inputs.host_matrix) }}
530+
531+
name: ${{ matrix.os }} ${{ matrix.arch }} mimalloc
532+
533+
steps:
534+
- uses: actions/checkout@v4
535+
with:
536+
repository: microsoft/mimalloc
537+
ref: ${{ inputs.mimalloc_revision }}
538+
path: ${{ github.workspace }}/SourceCache/mimalloc
539+
540+
- uses: compnerd/gha-setup-vsdevenv@f1ba60d553a3216ce1b89abe0201213536bc7557 # main
541+
with:
542+
host_arch: ${{ inputs.build_arch }}
543+
components: 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64;Microsoft.VisualStudio.Component.VC.Tools.ARM64'
544+
arch: ${{ matrix.arch }}
545+
546+
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # master
547+
548+
- name: Compute workspace hash
549+
id: workspace_hash
550+
run: |
551+
$stringAsStream = [System.IO.MemoryStream]::new()
552+
$writer = [System.IO.StreamWriter]::new($stringAsStream)
553+
$writer.write("${{ github.workspace }}")
554+
$writer.Flush()
555+
$stringAsStream.Position = 0
556+
$hash = (Get-FileHash -Algorithm SHA256 -InputStream $stringAsStream).Hash
557+
echo "hash=$hash" >> $env:GITHUB_OUTPUT
558+
559+
- name: Setup sccache
560+
uses: hendrikmuhs/ccache-action@2e0e89e8d74340a03f75d58d02aae4c5ee1b15c6
561+
with:
562+
max-size: 1M
563+
key: ${{ steps.workspace_hash.outputs.hash }}-${{ matrix.os }}-${{ matrix.arch }}-mimmalloc
564+
variant: sccache
565+
566+
- name: Configure mimalloc
567+
run: |
568+
cmake -B ${{ github.workspace }}/BinaryCache/mimalloc `
569+
-D CMAKE_BUILD_TYPE=Release `
570+
-D CMAKE_C_COMPILER=${{ matrix.cc }} `
571+
-D CMAKE_C_COMPILER_LAUNCHER=sccache `
572+
-D CMAKE_C_FLAGS="${{ matrix.cflags }}" `
573+
-D CMAKE_CXX_COMPILER=${{ matrix.cxx }} `
574+
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache `
575+
-D CMAKE_CXX_FLAGS="${{ matrix.cxxflags }}" `
576+
-D CMAKE_INSTALL_PREFIX=${{ github.workspace }}/BuildRoot/Library/mimalloc-3.0.1/usr `
577+
-D CMAKE_SYSTEM_NAME=${{ matrix.os }} `
578+
-D CMAKE_SYSTEM_PROCESSOR=${{ matrix.cpu }} `
579+
-G Ninja `
580+
-S ${{ github.workspace }}/SourceCache/mimalloc `
581+
-D MI_BUILD_OBJECT=NO `
582+
-D MI_BUILD_STATIC=NO `
583+
-D MI_BUILD_TESTS=NO `
584+
-D MI_OPT_SIMD=YES `
585+
-D MI_SKIP_COLLECT_ON_EXIT=YES `
586+
-D MI_WIN_USE_FIXED_TLS=YES
587+
588+
- name: Build mimalloc
589+
run: cmake --build ${{ github.workspace }}/BinaryCache/mimalloc
590+
591+
- name: Install mimalloc
592+
run: cmake --build ${{ github.workspace }}/BinaryCache/mimalloc --target install
593+
594+
- uses: actions/upload-artifact@v4
595+
with:
596+
name: mimalloc-${{ matrix.os }}-${{ matrix.arch }}
597+
path: ${{ github.workspace }}/BuildRoot/Library/mimalloc-3.0.1/usr
598+
523599
cmark_gfm:
524600
runs-on: ${{ inputs.default_build_runner }}
525601

0 commit comments

Comments
 (0)