LOG("Compiler type: {}", compiler_type_to_string(ctx.config.compiler_type()));
+ // Set CCACHE_DISABLE so no process ccache executes from now on will risk
+ // calling ccache second time. For instance, if the real compiler is a wrapper
+ // script that calls "ccache $compiler ..." we want that inner ccache call to
+ // be disabled.
+ Util::setenv("CCACHE_DISABLE", "1");
+
MTR_BEGIN("main", "process_args");
ProcessArgsResult processed = process_args(ctx);
MTR_END("main", "process_args");
expect_stat cache_miss 2
fi
+ # -------------------------------------------------------------------------
+ TEST "CCACHE_DISABLE set when executing compiler"
+
+ cat >compiler.sh <<EOF
+#!/bin/sh
+printf "%s" "\${CCACHE_DISABLE}" >>CCACHE_DISABLE.value
+exec $COMPILER "\$@"
+EOF
+ chmod +x compiler.sh
+ backdate compiler.sh
+ $CCACHE ./compiler.sh -c test1.c
+ expect_stat preprocessed_cache_hit 0
+ expect_stat cache_miss 1
+ expect_content CCACHE_DISABLE.value '11' # preprocessor + compiler
+
# -------------------------------------------------------------------------
TEST "CCACHE_COMPILER"
cat >compiler.sh <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
# A comment
EOF
cat >compiler.sh <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
cat >compiler.sh <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
cat >compiler.sh <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
cat >compiler.sh <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
cat >compiler.sh <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
printf "cc_err|" >&2
printf "cc_out|"
fi
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
exec $COMPILER "\$@"
EOF
chmod +x compiler.sh
cat >buggy-cpp <<EOF
#!/bin/sh
-CCACHE_DISABLE=1 # If $COMPILER happens to be a ccache symlink...
-export CCACHE_DISABLE
if echo "\$*" | grep -- -D >/dev/null; then
$COMPILER "\$@"
else