Skip to content

[Runner] Prevent CCACHE env var from affecting compiler wrappers #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
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
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
Loading