From ccbbf3743e697e256308040fbe964b86e1fade16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= <765740+giordano@users.noreply.github.com> Date: Sun, 26 Jan 2025 07:06:06 +0100 Subject: [PATCH] [Runner] Prevent `CCACHE` env var from affecting compiler wrappers (#406) --- src/Runner.jl | 5 ++++- test/runners.jl | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Runner.jl b/src/Runner.jl index 5786ab23..ede32b7f 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -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 diff --git a/test/runners.jl b/test/runners.jl index 0b48a6b3..3f7c5fa0 100644 --- a/test/runners.jl +++ b/test/runners.jl @@ -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 @@ -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