Ray's Knowledge Base
Unlock

sccache fails on vectorscan's fat-runtime objects because build_wrapper.sh reruns the compile with --print-file-name

PitfallVerified 8 Oct 2026Holds project: dftracer-utils
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

With CMAKE_C_COMPILER_LAUNCHER=sccache and CMAKE_CXX_COMPILER_LAUNCHER=sccache, the vectorscan sub-build (Linux, x86_64 or aarch64) fails on every hs_exec_* object: FAILED: [code=254] CMakeFiles/hs_exec_core2.dir/src/hwlm/hwlm.c.o, with the command .../cmake/build_wrapper.sh core2 .../keep.syms.in sccache /usr/bin/cc ... -o X.o -c file.c, then sccache: error: failed to zip up compiler outputs and failed to open file ...hwlm.c.o: No such file or directory (os error 2). The same build works with ccache.

Cause#

Vectorscan builds its fat runtime with RULE_LAUNCH_COMPILE "build_wrapper.sh <prefix> keep.syms.in". The wrapper runs the whole compile command again with --print-file-name=libc.so.6 appended, to find libc. gcc prints the path and does not compile. ccache sees an unsupported option and passes the command through. sccache takes the command for a real compile and then looks for the object file, which does not exist. The wrapper also renames symbols in the object with objcopy after the compile.

Fix#

Give the vectorscan sub-build a small launcher instead of sccache: cmake/scripts/sccache_launcher.sh loops over its arguments. If one matches --print-* or -print-*, it runs exec "$@" (the real compiler). Otherwise it runs exec sccache "$@". In cmake/modules/Dependencies.cmake, where the launcher is passed to the vectorscan ExternalProject, replace a launcher named sccache by that script. Do not just skip the launcher for vectorscan: on x86 Linux vectorscan took 32 CPU-minutes (4 min 24 s on 8 cores) to build. The wrapper's symbol renaming still runs after every compile, on the object that sccache returns (also on a cache hit).

Evidence#

Reproduced and fixed on an x86-64 Linux host with sccache 0.18.0: before, cmake --build <dir> --target dftracer_utils_vectorscan_ep gave rc=254 with failed to zip up compiler outputs. After: cold rc=0 in 275 s (386 requests, 385 misses, 0 errors), warm rebuild at the same path rc=0 in 11 s with 386 of 386 hits, and all 386 .o files matched the build without any cache byte for byte (find . -name '*.o' | sort | xargs sha256sum). Not tested on aarch64 Linux.

Also found by searching

  • sccache: error: failed to zip up compiler outputs ... hs_exec_core2.dir/src/hwlm/hwlm.c.o No such file or directory
  • FAILED: [code=254] CMakeFiles/hs_exec_core2.dir build_wrapper.sh core2 keep.syms.in sccache /usr/bin/cc
  • CMAKE_C_COMPILER_LAUNCHER=sccache breaks the vectorscan build
  • how do I use sccache with a project that wraps the compile command in a shell script