[llvm] [libc] Include CPU model in overlay CI sccache key (PR #196477)
Jeff Bailey via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 23:50:12 PDT 2026
https://github.com/kaladron updated https://github.com/llvm/llvm-project/pull/196477
>From 9ef656e1b612793e33c3c63d2bb18f946e872e4e Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Fri, 8 May 2026 07:46:17 +0100
Subject: [PATCH 1/2] [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 are served to runners
with a different CPU. When the cached binary uses instructions
the current CPU lacks, the test crashes with SIGILL.
Added a Detect CPU Model step that captures the CPU model string
and includes it in the sccache cache key. Runners with different
CPUs now get separate cache buckets, preventing cross-CPU cache
poisoning.
Assisted-by: Automated tooling, human reviewed.
---
.github/workflows/libc-overlay-tests.yml | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
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.
>From eea69c08e8f8c506ac2394428aac7f61f1af1c49 Mon Sep 17 00:00:00 2001
From: Jeff Bailey <jbailey at raspberryginger.com>
Date: Fri, 8 May 2026 07:49:57 +0100
Subject: [PATCH 2/2] Fix ARM Linux CPU detection
ARM /proc/cpuinfo lacks a model name field. Fall back to CPU
implementer + CPU part for ARM. Guard the grep with || true to
prevent pipefail from aborting on a missing field.
Assisted-by: Automated tooling, human reviewed.
---
.github/workflows/libc-overlay-tests.yml | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/libc-overlay-tests.yml b/.github/workflows/libc-overlay-tests.yml
index 96c3e23bc4896..a020f0bfd5cd3 100644
--- a/.github/workflows/libc-overlay-tests.yml
+++ b/.github/workflows/libc-overlay-tests.yml
@@ -56,13 +56,19 @@ jobs:
shell: bash
run: |
if [ "$RUNNER_OS" = "Linux" ]; then
- cpu_model=$(cat /proc/cpuinfo | grep 'model name' | head -1 | cut -d: -f2 | xargs | tr ' ' '-')
+ # x86 has 'model name', ARM has 'CPU implementer' + 'CPU part'.
+ cpu_model=$(grep -m1 'model name' /proc/cpuinfo | cut -d: -f2 | xargs | tr ' ' '-' || true)
+ if [ -z "$cpu_model" ]; then
+ impl=$(grep -m1 'CPU implementer' /proc/cpuinfo | cut -d: -f2 | xargs)
+ part=$(grep -m1 'CPU part' /proc/cpuinfo | cut -d: -f2 | xargs)
+ cpu_model="arm-${impl:-unknown}-${part:-unknown}"
+ fi
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"
+ echo "cpu-model=${cpu_model:-unknown}" >> "$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
More information about the llvm-commits
mailing list