Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions scripts/build-llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ if [[ "$USE_SCCACHE" != "0" && -n "$SCCACHE_BIN" ]] &&
fi

if [[ "$USE_SCCACHE" != "0" && -n "$SCCACHE_BIN" ]]; then
CMAKE_ARGS+=(
-DCMAKE_C_COMPILER_LAUNCHER="$SCCACHE_BIN"
-DCMAKE_CXX_COMPILER_LAUNCHER="$SCCACHE_BIN"
)
if [[ "$(uname -s)" == "Darwin" && "$LLAMA_BACKEND" == "metal" ]]; then
# The embedded Metal source is pulled into an assembly object with .incbin.
# sccache does not include that payload in the assembly cache key.
CMAKE_ARGS+=(-DCMAKE_C_COMPILER_LAUNCHER=)
else
CMAKE_ARGS+=(-DCMAKE_C_COMPILER_LAUNCHER="$SCCACHE_BIN")
fi
CMAKE_ARGS+=(-DCMAKE_CXX_COMPILER_LAUNCHER="$SCCACHE_BIN")
case "$LLAMA_BACKEND" in
cuda)
CMAKE_ARGS+=(-DCMAKE_CUDA_COMPILER_LAUNCHER="$SCCACHE_BIN")
Expand All @@ -218,11 +222,23 @@ if [[ "$USE_SCCACHE" != "0" && -n "$SCCACHE_BIN" ]]; then
CMAKE_ARGS+=(-DCMAKE_HIP_COMPILER_LAUNCHER="$SCCACHE_BIN")
;;
esac
echo "using sccache for llama.cpp C/C++ compilation: $SCCACHE_BIN"
echo "using sccache for llama.cpp compilation where safe: $SCCACHE_BIN"
elif [[ "$USE_SCCACHE" != "0" ]]; then
echo "sccache not found; llama.cpp build will run without compiler caching" >&2
CMAKE_ARGS+=(
-DCMAKE_C_COMPILER_LAUNCHER=
-DCMAKE_CXX_COMPILER_LAUNCHER=
-DCMAKE_CUDA_COMPILER_LAUNCHER=
-DCMAKE_HIP_COMPILER_LAUNCHER=
)
Comment on lines +228 to +233

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Explicitly disable GGML_CCACHE to prevent unintended fallback to ccache.

The log message on line 227 states that the build will run "without compiler caching." However, because llama.cpp defaults GGML_CCACHE to ON, it will automatically search for ccache and overwrite the explicitly cleared compiler launchers if ccache happens to be installed on the system.

To ensure caching is truly disabled when sccache is not found, pass -DGGML_CCACHE=OFF, mirroring the else branch below.

💻 Proposed fix
   CMAKE_ARGS+=(
+    -DGGML_CCACHE=OFF
     -DCMAKE_C_COMPILER_LAUNCHER=
     -DCMAKE_CXX_COMPILER_LAUNCHER=
     -DCMAKE_CUDA_COMPILER_LAUNCHER=
     -DCMAKE_HIP_COMPILER_LAUNCHER=
   )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CMAKE_ARGS+=(
-DCMAKE_C_COMPILER_LAUNCHER=
-DCMAKE_CXX_COMPILER_LAUNCHER=
-DCMAKE_CUDA_COMPILER_LAUNCHER=
-DCMAKE_HIP_COMPILER_LAUNCHER=
)
CMAKE_ARGS+=(
-DGGML_CCACHE=OFF
-DCMAKE_C_COMPILER_LAUNCHER=
-DCMAKE_CXX_COMPILER_LAUNCHER=
-DCMAKE_CUDA_COMPILER_LAUNCHER=
-DCMAKE_HIP_COMPILER_LAUNCHER=
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build-llama.sh` around lines 228 - 233, When sccache is unavailable,
update the CMAKE_ARGS fallback block to explicitly add -DGGML_CCACHE=OFF
alongside the cleared compiler launcher settings. Keep the existing no-caching
behavior and mirror the corresponding setting in the else branch.

else
CMAKE_ARGS+=(-DGGML_CCACHE=OFF)
CMAKE_ARGS+=(
-DGGML_CCACHE=OFF
-DCMAKE_C_COMPILER_LAUNCHER=
-DCMAKE_CXX_COMPILER_LAUNCHER=
-DCMAKE_CUDA_COMPILER_LAUNCHER=
-DCMAKE_HIP_COMPILER_LAUNCHER=
)
fi

if [[ "$#" -gt 0 ]]; then
Expand Down
Loading