Skip to content

Commit 2b0fcf5

Browse files
Merge pull request #248 from bernardladenthin/claude/exciting-fermi-ltkrku
Add Windows Ninja Multi-Config build with sccache caching
2 parents 1277580 + eb04589 commit 2b0fcf5

17 files changed

Lines changed: 879 additions & 96 deletions

.github/build.bat

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,49 @@ REM
44
REM SPDX-License-Identifier: MIT
55

66
@echo off
7+
setlocal enabledelayedexpansion
8+
9+
REM ---------------------------------------------------------------------------
10+
REM Optional shared compiler cache: sccache fronting Depot Cache (WebDAV).
11+
REM Mirrors build.sh's sccache_can_wrap_compiler() probe. Because sccache *is*
12+
REM the compiler launcher (cmake runs `sccache cl.exe ...` for every TU), a
13+
REM present-but-crashing sccache would red every build; so we trust it only after
14+
REM a trivial TU compiles *through* it. Enabled only when USE_CACHE=true AND
15+
REM sccache is on PATH AND the probe succeeds; otherwise the build proceeds
16+
REM uncached and green. The Visual Studio generator jobs do NOT set USE_CACHE, so
17+
REM this stays inert for them (and the VS generator ignores
18+
REM CMAKE_{C,CXX}_COMPILER_LAUNCHER anyway -- only Ninja/Makefiles honor it).
19+
REM ---------------------------------------------------------------------------
20+
set "LAUNCH="
21+
if /I "%USE_CACHE%"=="true" (
22+
where sccache >nul 2>&1
23+
if errorlevel 1 (
24+
echo build.bat: USE_CACHE=true but sccache not on PATH; building WITHOUT cache.
25+
) else (
26+
set "PROBE_DIR=%TEMP%\sccache-probe-%RANDOM%"
27+
mkdir "!PROBE_DIR!" >nul 2>&1
28+
(echo int sccache_probe_verify = 0;)> "!PROBE_DIR!\probe.c"
29+
sccache cl.exe /nologo /c "!PROBE_DIR!\probe.c" /Fo"!PROBE_DIR!\probe.obj" > "!PROBE_DIR!\probe.log" 2>&1
30+
if errorlevel 1 (
31+
echo build.bat: sccache probe FAILED wrapping cl.exe -- building WITHOUT cache.
32+
type "!PROBE_DIR!\probe.log"
33+
) else (
34+
echo build.bat: sccache probe OK ^(wrapped cl.exe^).
35+
set "LAUNCH=-DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
36+
)
37+
rmdir /s /q "!PROBE_DIR!" >nul 2>&1
38+
)
39+
)
740

841
mkdir build
9-
cmake -Bbuild %*
42+
cmake -Bbuild %LAUNCH% %*
43+
if errorlevel 1 exit /b %ERRORLEVEL%
1044
cmake --build build --config Release
45+
if errorlevel 1 exit /b %ERRORLEVEL%
1146

12-
if errorlevel 1 exit /b %ERRORLEVEL%
47+
REM Only query stats when sccache was actually wired in as the launcher; re-invoking
48+
REM a rejected/crashing sccache here would just repeat its failure output.
49+
if defined LAUNCH (
50+
echo build.bat: sccache --show-stats
51+
sccache --show-stats
52+
)

.github/build.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,24 @@ fi
1919
# Fetch sccache when caching is requested but the runner/container doesn't ship it — the
2020
# dockcross cross-compile containers (manylinux/Android) and Linux hosts have no sccache,
2121
# while macOS installs it via brew in the workflow. Best-effort and inert-safe: any failure
22-
# leaves sccache absent, so the build just proceeds uncached. The static musl binary runs in
23-
# any x86_64 Linux container (the cross-compile host is always x86_64).
22+
# leaves sccache absent, so the build just proceeds uncached. A static musl release exists for
23+
# both Linux arches we build on: x86_64 (the dockcross cross-compile hosts) and aarch64 (the
24+
# native ubuntu-24.04-arm runner); any other arch leaves SCCACHE_DL_ARCH empty and is skipped.
2425
#
2526
# SCCACHE_DL_VERSION is overridable per-job, so a container that crashes one sccache build can
2627
# try another without editing this script (the in-container panic that stalled phase 2 was on
2728
# v0.8.2; v0.16.0 is the latest release and the default). A wrong/unavailable version just fails
2829
# the `curl -f` and falls back to an uncached build, so bumping it can never red a build.
2930
SCCACHE_DL_VERSION="${SCCACHE_DL_VERSION:-0.16.0}"
31+
case "$(uname -m)" in
32+
x86_64) SCCACHE_DL_ARCH="x86_64" ;;
33+
aarch64|arm64) SCCACHE_DL_ARCH="aarch64" ;;
34+
*) SCCACHE_DL_ARCH="" ;;
35+
esac
3036
if [ "${USE_CACHE:-true}" = "true" ] && [ -n "${SCCACHE_WEBDAV_TOKEN:-}${SCCACHE_GHA_ENABLED:-}" ] \
3137
&& ! command -v sccache >/dev/null 2>&1 \
32-
&& [ "$(uname -s)" = "Linux" ] && [ "$(uname -m)" = "x86_64" ]; then
33-
SCCACHE_REL="sccache-v${SCCACHE_DL_VERSION}-x86_64-unknown-linux-musl"
38+
&& [ "$(uname -s)" = "Linux" ] && [ -n "$SCCACHE_DL_ARCH" ]; then
39+
SCCACHE_REL="sccache-v${SCCACHE_DL_VERSION}-${SCCACHE_DL_ARCH}-unknown-linux-musl"
3440
echo "build.sh: fetching ${SCCACHE_REL} (no sccache on PATH)..."
3541
if curl -fsSL --proto =https --proto-redir =https \
3642
"https://github.com/mozilla/sccache/releases/download/v${SCCACHE_DL_VERSION}/${SCCACHE_REL}.tar.gz" \

.github/workflows/clang-format.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ jobs:
2323
with:
2424
python-version: "3.x"
2525
- name: Install pinned clang-format
26-
run: pip install "clang-format==${CLANG_FORMAT_VERSION}"
26+
# --only-binary :all: forces pip to install from a prebuilt wheel and never run a
27+
# source package's setup.py at install time (SonarCloud GHA security rule). clang-format
28+
# ships manylinux wheels, so this resolves normally on the ubuntu runner.
29+
run: |
30+
pip install --only-binary :all: "clang-format==${CLANG_FORMAT_VERSION}"
2731
- name: Check C++ formatting
2832
run: |
2933
clang-format --version

.github/workflows/osv-scanner.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ on:
1313
- cron: '0 6 * * 1'
1414
workflow_dispatch:
1515

16-
permissions: read-all
16+
permissions:
17+
contents: read
1718

1819
jobs:
1920
scan-scheduled:

0 commit comments

Comments
 (0)