@@ -104,10 +104,37 @@ else
104104fi
105105
106106cmake -Bbuild $LAUNCH $@ || exit 1
107- cmake --build build --config Release -j" ${JOBS} " || exit 1
107+
108+ # Build. The pre-build probe only proves the cache was reachable at one instant; it cannot
109+ # foresee a cache outage that strikes *during* the build. When sccache is the launcher and its
110+ # backend fails mid-build — e.g. an intermittent Depot 403 on the server-startup .sccache_check,
111+ # or the tokenless 403 a fork PR hits because secrets are withheld — sccache makes every TU fatal
112+ # and reds the whole build. sccache exposes no "ignore backend errors" switch for that startup
113+ # check, so recover by retrying the build once WITHOUT the launcher: a from-scratch uncached -O3
114+ # build is content-identical and release-safe, so the cache can never red the build. The retry is
115+ # gated on the failure output actually showing an sccache cache error, so a genuine compile error
116+ # still fails fast (and is reported) instead of triggering a wasteful uncached rebuild.
117+ build_log=" $( mktemp 2> /dev/null || echo " /tmp/jllama-build.$$ .log" ) "
118+ cmake --build build --config Release -j" ${JOBS} " 2>&1 | tee " $build_log "
119+ build_rc=${PIPESTATUS[0]}
120+ if [ " $build_rc " -ne 0 ]; then
121+ if [ -n " $LAUNCH " ] && grep -qiE ' sccache: error|Server startup failed|cache storage failed' " $build_log " ; then
122+ echo " build.sh: build failed via an sccache cache error — retrying WITHOUT cache (clean reconfigure)."
123+ rm -f " $build_log "
124+ rm -rf build && mkdir -p build
125+ cmake -Bbuild $@ || exit 1
126+ cmake --build build --config Release -j" ${JOBS} " || exit 1
127+ LAUNCH=" " # cache disabled for this run; skip the stats query below
128+ else
129+ rm -f " $build_log "
130+ exit 1
131+ fi
132+ fi
133+ rm -f " $build_log "
108134
109135# Only query stats when sccache was actually used as the launcher; if the probe rejected a
110- # crashing sccache, re-invoking it here would just repeat the crash output (harmless but noisy).
136+ # crashing sccache (or the mid-build retry disabled it), re-invoking it here would just repeat
137+ # the crash output (harmless but noisy).
111138if [ -n " $LAUNCH " ] && command -v sccache > /dev/null 2>&1 ; then
112139 sccache --show-stats || true
113140fi
0 commit comments