Repository navigation
Fix CI ccache SIGILL by keying on the resolved ISA #1630
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| paths: | |
| - '.github/workflows/continuous.yml' | |
| - 'cmake/**' | |
| - 'src/**' | |
| - 'tests/**' | |
| - 'CMakeLists.txt' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} | |
| env: | |
| CTEST_OUTPUT_ON_FAILURE: ON | |
| CTEST_PARALLEL_LEVEL: 2 | |
| jobs: | |
| Build: | |
| name: ${{ matrix.name }} (${{ matrix.config }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| config: [Debug, Release] | |
| include: | |
| - os: macos-latest | |
| name: macOS | |
| - os: ubuntu-latest | |
| name: Linux | |
| - os: windows-latest | |
| name: Windows | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 10 | |
| - name: Dependencies (Linux) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get install ccache | |
| echo 'CACHE_PATH=~/.cache/ccache' >> "$GITHUB_ENV" | |
| - name: Dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install ccache | |
| echo 'CACHE_PATH=~/Library/Caches/ccache' >> "$GITHUB_ENV" | |
| - name: Dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install ccache | |
| "CACHE_PATH=${env:LOCALAPPDATA}\ccache" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| # Install Ninja (only needed on Windows) | |
| - name: Install Ninja | |
| if: runner.os == 'Windows' | |
| uses: seanmiddleditch/gha-setup-ninja@master | |
| - name: Setup MSVC (Windows) | |
| if: runner.os == 'Windows' | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| with: | |
| arch: x64 | |
| - name: Get number of CPU cores | |
| uses: SimenB/github-actions-cpu-cores@v2 | |
| id: cpu-cores | |
| # FindSIMD, MeshFEMCore, and Tight-Inclusion all compile with | |
| # -march=native, which bakes the building runner's ISA into every cached | |
| # object file. ccache hashes the literal flag string, not what it expands | |
| # to, so restored objects are only safe on a runner with the same ISA. | |
| # The CPU model name has not been enough to guarantee that: EPYC 9V74 | |
| # runners restored each other's objects and crashed with SIGILL. On Linux | |
| # we also hash the flags the compiler expands -march=native to, which is | |
| # exactly what ends up in the object files. We keep the model name in the | |
| # hash too, so the key is never weaker than before. | |
| - name: CPU fingerprint (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| if [ "$RUNNER_OS" = "Linux" ]; then | |
| CPU=$(grep -m1 '^model name' /proc/cpuinfo | cut -d: -f2-) | |
| ISA=$(echo | c++ -march=native -E -v - 2>&1 | grep -oE -- ' -m[a-z0-9=._+-]+' | sort -u | tr -d '\n') | |
| echo "ISA:$ISA" | |
| KEY=$(printf '%s\n%s' "$CPU" "$ISA" | sha256sum | cut -c1-12) | |
| else | |
| CPU=$(sysctl -n machdep.cpu.brand_string) | |
| KEY=$(printf '%s' "$CPU" | shasum -a 256 | cut -c1-12) | |
| fi | |
| echo "CPU: $CPU" | |
| echo "CPU_KEY=$KEY" >> "$GITHUB_ENV" | |
| - name: CPU fingerprint (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| $cpu = Get-CimInstance Win32_Processor | Select-Object -First 1 -ExpandProperty Name | |
| Write-Host "CPU: $cpu" | |
| $stream = [IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($cpu)) | |
| $key = (Get-FileHash -InputStream $stream -Algorithm SHA256).Hash.Substring(0, 12) | |
| "CPU_KEY=$key" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Cache Build | |
| id: cache-build | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ env.CACHE_PATH }} | |
| key: ${{ runner.os }}-${{ matrix.config }}-${{ env.CPU_KEY }}-cache | |
| - name: Prepare ccache | |
| run: | | |
| ccache --max-size=1.0G | |
| ccache -V && ccache --show-config | |
| ccache --show-stats && ccache --zero-stats | |
| - name: Configure (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| mkdir -p build | |
| cd build | |
| cmake .. \ | |
| -DIPC_TOOLKIT_BUILD_TESTS=ON \ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.config }} | |
| - name: Configure (Windows) | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: | | |
| cmake -G Ninja ^ | |
| -DIPC_TOOLKIT_BUILD_TESTS=ON ^ | |
| -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^ | |
| -B build ^ | |
| -S . | |
| - name: Build (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| cmake --build build -j ${{ steps.cpu-cores.outputs.count }} | |
| ccache --show-stats | |
| - name: Build (Windows) | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: | | |
| cmake --build build -j ${{ steps.cpu-cores.outputs.count }} && ccache --show-stats | |
| - name: Tests | |
| run: cd build; ctest --verbose -j ${{ steps.cpu-cores.outputs.count }} |