Skip to content

Commit ccbbf37

Browse files
authored
[Runner] Prevent CCACHE env var from affecting compiler wrappers (#406)
1 parent 087e705 commit ccbbf37

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Runner.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,16 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
319319

320320
if allow_ccache
321321
write(io, """
322+
# Override `\${CCACHE}` setting from the outside.
323+
CCACHE=""
322324
if [[ \${USE_CCACHE} == "true" ]]; then
323325
CCACHE="ccache"
324326
fi
325327
""")
326328
end
329+
# Don't evaluate `${CCACHE}` at all if not allowed in the first place.
327330
write(io, """
328-
vrun \${CCACHE} $(prog) "\${PRE_FLAGS[@]}" "\${ARGS[@]}" "\${POST_FLAGS[@]}"
331+
vrun $(allow_ccache ? "\${CCACHE} " : "")$(prog) "\${PRE_FLAGS[@]}" "\${ARGS[@]}" "\${POST_FLAGS[@]}"
329332
""")
330333
end
331334

test/runners.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ end
177177
"""
178178
test_script = """
179179
set -e
180+
# Make sure setting `CCACHE` doesn't affect the compiler wrappers.
181+
export CCACHE=pwned
182+
export USE_CCACHE=false
180183
echo '$(test_c)' > test.c
181184
echo '$(main_c)' > main.c
182185
# Build object file
@@ -222,6 +225,9 @@ end
222225
set -e
223226
echo '$(test_cpp)' > test.cpp
224227
echo '$(main_cpp)' > main.cpp
228+
# Make sure setting `CCACHE` doesn't affect the compiler wrappers.
229+
export CCACHE=pwned
230+
export USE_CCACHE=true
225231
# Build object file
226232
$(compiler) $(needfpic) -Werror -std=c++11 -c test.cpp -o test.o
227233
# Link shared library

0 commit comments

Comments
 (0)