The script takes only its first argument as the compiler, so a $(CC) that
carries a wrapper, e.g. "sccache clang-21", makes it probe the wrapper
instead.

This leads to CLANG_RUNTIME_DIR ending up up empty and the sandbox
fuzzer link then fails with

  ld.lld: error: undefined symbol: LLVMFuzzerRunDriver

because -L"" no longer finds libclang_rt.fuzzer_no_main.

Pass all arguments through instead.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Ahmad Fatoum <[email protected]>
---
 scripts/clang-runtime-dir.sh | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/clang-runtime-dir.sh b/scripts/clang-runtime-dir.sh
index 65b3028ad04d..7a3899d16ee2 100755
--- a/scripts/clang-runtime-dir.sh
+++ b/scripts/clang-runtime-dir.sh
@@ -1,14 +1,17 @@
 #!/bin/sh
 
-CC=${1:-${CC}}
+if [ $# -eq 0 ]; then
+       # unquoted on purpose: $CC may carry a wrapper, e.g. "sccache clang-21"
+       set -- ${CC}
+fi
 
-if [ "${CC}" = "" ]; then
+if [ $# -eq 0 ]; then
        echo "Error: No compiler specified." >&2
        printf "Usage:\n\t$0 <clang-command>\n" >&2
        exit 1
 fi
 
-rundir=$("${CC}" --print-runtime-dir 2>/dev/null)
+rundir=$("$@" --print-runtime-dir 2>/dev/null)
 if [ ! -e "$rundir" ]; then
        # Workaround https://github.com/llvm/llvm-project/issues/112458
        guess=$(dirname "$rundir")/linux
-- 
2.47.3


Reply via email to