Skip to content

Commit

Permalink
[Runner] Prevent CCACHE env var from affecting compiler wrappers (#406
Browse files Browse the repository at this point in the history
)
  • Loading branch information
giordano authored Jan 26, 2025
1 parent 087e705 commit ccbbf37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,16 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr

if allow_ccache
write(io, """
# Override `\${CCACHE}` setting from the outside.
CCACHE=""
if [[ \${USE_CCACHE} == "true" ]]; then
CCACHE="ccache"
fi
""")
end
# Don't evaluate `${CCACHE}` at all if not allowed in the first place.
write(io, """
vrun \${CCACHE} $(prog) "\${PRE_FLAGS[@]}" "\${ARGS[@]}" "\${POST_FLAGS[@]}"
vrun $(allow_ccache ? "\${CCACHE} " : "")$(prog) "\${PRE_FLAGS[@]}" "\${ARGS[@]}" "\${POST_FLAGS[@]}"
""")
end

Expand Down
6 changes: 6 additions & 0 deletions test/runners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ end
"""
test_script = """
set -e
# Make sure setting `CCACHE` doesn't affect the compiler wrappers.
export CCACHE=pwned
export USE_CCACHE=false
echo '$(test_c)' > test.c
echo '$(main_c)' > main.c
# Build object file
Expand Down Expand Up @@ -222,6 +225,9 @@ end
set -e
echo '$(test_cpp)' > test.cpp
echo '$(main_cpp)' > main.cpp
# Make sure setting `CCACHE` doesn't affect the compiler wrappers.
export CCACHE=pwned
export USE_CCACHE=true
# Build object file
$(compiler) $(needfpic) -Werror -std=c++11 -c test.cpp -o test.o
# Link shared library
Expand Down

0 comments on commit ccbbf37

Please sign in to comment.