[llvm] [libc] Include CPU model in overlay CI sccache key (PR #196477)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 23:47:46 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-github-workflow
Author: Jeff Bailey (kaladron)
<details>
<summary>Changes</summary>
[libc] Include CPU model in overlay CI sccache key
The overlay CI compiles opt_host memory tests with `-march=native`, which generates object files specific to the runner CPU model. sccache treats `-march=native` as a literal string in its hash key, so cached `.o` files compiled on one CPU model get served to runners with a different CPU. When the cached binary uses instructions the current CPU lacks, the test crashes with SIGILL.
## Symptoms
The `memcmp_opt_host`, `memmove_opt_host`, `memset_opt_host`, `bcmp_opt_host`, and `bzero_opt_host` tests crash immediately when SIMD code paths are exercised (e.g., `Issue77080` for memcmp, `SizeSweep` for memmove/memset). Simple non-SIMD tests pass. The failures are fully reproducible on reruns because the cache stays poisoned.
## Evidence
| Run | Cache Hits | Cache Misses | Result |
|-----|-----------|-------------|--------|
| Clean build (westus3) | 9 | 5354 | PASS |
| Cached build (northcentralus) | 5345 | 0 | CRASH |
| Cached rerun (westus) | 5345 | 0 | CRASH |
| Same-CPU build (eastus) | — | — | PASS |
## Fix
Added a "Detect CPU model" step that reads the CPU model string from `/proc/cpuinfo` (Linux) or `sysctl` (macOS) and appends it to the sccache cache key. Runners with different CPUs now get separate cache buckets.
Assisted-by: Automated tooling, human reviewed.
---
Full diff: https://github.com/llvm/llvm-project/pull/196477.diff
1 Files Affected:
- (modified) .github/workflows/libc-overlay-tests.yml (+20-1)
``````````diff
diff --git a/.github/workflows/libc-overlay-tests.yml b/.github/workflows/libc-overlay-tests.yml
index 07059e0271af5..96c3e23bc4896 100644
--- a/.github/workflows/libc-overlay-tests.yml
+++ b/.github/workflows/libc-overlay-tests.yml
@@ -44,6 +44,25 @@ jobs:
- uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
+
+ # The libc build uses -march=native for opt_host tests, which means
+ # the generated object files are specific to the runner's CPU model.
+ # sccache treats -march=native as a literal string in its cache key,
+ # so without per-CPU cache keys, object files compiled on one CPU
+ # model are silently served to runners with a different CPU, causing
+ # illegal instruction crashes at runtime.
+ - name: Detect CPU model
+ id: cpu-info
+ shell: bash
+ run: |
+ if [ "$RUNNER_OS" = "Linux" ]; then
+ cpu_model=$(cat /proc/cpuinfo | grep 'model name' | head -1 | cut -d: -f2 | xargs | tr ' ' '-')
+ elif [ "$RUNNER_OS" = "macOS" ]; then
+ cpu_model=$(sysctl -n machdep.cpu.brand_string | tr ' ' '-')
+ else
+ cpu_model="generic"
+ fi
+ echo "cpu-model=${cpu_model}" >> "$GITHUB_OUTPUT"
# Libc's build is relatively small comparing with other components of LLVM.
# A fresh linux overlay takes about 180MiB of uncompressed disk space, which can
@@ -56,7 +75,7 @@ jobs:
uses: hendrikmuhs/ccache-action at 33522472633dbd32578e909b315f5ee43ba878ce # v1.2.22
with:
max-size: 1G
- key: libc_overlay_build_${{ matrix.os }}_${{ matrix.compiler.c_compiler }}
+ key: libc_overlay_build_${{ matrix.os }}_${{ matrix.compiler.c_compiler }}_${{ steps.cpu-info.outputs.cpu-model }}
variant: sccache
# MPFR is required by some of the mathlib tests.
``````````
</details>
https://github.com/llvm/llvm-project/pull/196477
More information about the llvm-commits
mailing list