exit 1
}
+find_compiler() {
+ local name=$1
+ perl -e '
+ use File::Basename;
+ my $cc = $ARGV[0];
+ $cc = basename($cc) if readlink($cc) =~ "ccache";
+ if ($cc =~ m!^/!) {
+ print $cc;
+ exit;
+ }
+ foreach my $dir (split(/:/, $ENV{PATH})) {
+ $path = "$dir/$cc";
+ if (-x $path && readlink($path) !~ "ccache") {
+ print $path;
+ exit;
+ }
+ }' $name
+}
+
generate_code() {
local nlines=$1
local outfile=$2
local suite_name=$1
CURRENT_SUITE=$suite_name
- UNCACHED_COMPILE=uncached_compile
cd $ABS_TESTDIR
rm -rf $ABS_TESTDIR/fixture
echo
}
-uncached_compile() {
- # $COMPILER could be a masquerading system ccache, so make sure it's
- # disabled:
- CCACHE_DISABLE=1 $COMPILER "$@"
-}
-
TEST() {
CURRENT_TEST=$1
# -------------------------------------------------------------------------
TEST "Base case"
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
$CCACHE_COMPILE -c test1.c
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c -g
+ $REAL_COMPILER -c -o reference_test1.o test1.c -g
expect_equal_object_files reference_test1.o reference_test1.o
# -------------------------------------------------------------------------
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o foo.o
# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
TEST "CCACHE_COMMENTS"
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
mv test1.c test1-saved.c
echo '// initial comment' >test1.c
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 2
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o test1.o
# -------------------------------------------------------------------------
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 2
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o test1.o
expect_stat 'files in cache' 1
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
expect_equal_object_files reference_test1.o test1.o
# -------------------------------------------------------------------------
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 1
- $UNCACHED_COMPILE -c test1.c -E >test1.i
+ $REAL_COMPILER -c test1.c -E >test1.i
$CCACHE_COMPILE -c test1.i
expect_stat 'cache hit (preprocessed)' 1
expect_stat 'cache miss' 1
ln -s d1/d2 d3
CCACHE_BASEDIR=/ $CCACHE_COMPILE -c $PWD/d3/c.c
- $UNCACHED_COMPILE c.o -o c
+ $REAL_COMPILER c.o -o c
if [ "$(./c)" != OK ]; then
test_failed "Incorrect header file used"
fi
ln -s d/c.c c.c
CCACHE_BASEDIR=/ $CCACHE_COMPILE -c $PWD/c.c
- $UNCACHED_COMPILE c.o -o c
+ $REAL_COMPILER c.o -o c
if [ "$(./c)" != OK ]; then
test_failed "Incorrect header file used"
fi
SUITE_serialize_diagnostics_PROBE() {
touch test.c
- if ! $UNCACHED_COMPILE -c --serialize-diagnostics \
+ if ! $REAL_COMPILER -c --serialize-diagnostics \
test1.dia test.c 2>/dev/null; then
echo "--serialize-diagnostics not supported by compiler"
fi
# -------------------------------------------------------------------------
TEST "Compile OK"
- $UNCACHED_COMPILE -c --serialize-diagnostics expected.dia test1.c
+ $REAL_COMPILER -c --serialize-diagnostics expected.dia test1.c
$CCACHE_COMPILE -c --serialize-diagnostics test.dia test1.c
expect_stat 'cache hit (preprocessed)' 0
TEST "Compile failed"
echo "bad source" >error.c
- if $UNCACHED_COMPILE -c --serialize-diagnostics expected.dia error.c 2>expected.stderr; then
+ if $REAL_COMPILER -c --serialize-diagnostics expected.dia error.c 2>expected.stderr; then
test_failed "Expected an error compiling error.c"
fi
# -------------------------------------------------------------------------
TEST "Masquerading via symlink"
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
$CCACHE_COMPILE -c test1.c
expect_stat 'cache hit (preprocessed)' 0
generate_code 1 test1.c
- $UNCACHED_COMPILE -c -o reference_test1.o test1.c
+ $REAL_COMPILER -c -o reference_test1.o test1.c
$CCACHE_COMPILE -c test1.c
expect_stat 'cache hit (preprocessed)' 0
EOF
backdate test1.h test2.h test3.h
- $UNCACHED_COMPILE -c -Wp,-MD,expected.d test.c
- $UNCACHED_COMPILE -c -Wp,-MMD,expected_mmd.d test.c
+ $REAL_COMPILER -c -Wp,-MD,expected.d test.c
+ $REAL_COMPILER -c -Wp,-MMD,expected_mmd.d test.c
rm test.o
}
# -------------------------------------------------------------------------
TEST "Base case"
- $UNCACHED_COMPILE -c -o reference_test.o test.c
+ $REAL_COMPILER -c -o reference_test.o test.c
$CCACHE_COMPILE -c test.c
expect_stat 'cache hit (direct)' 0
expect_stat 'cache miss' 1
expect_equal_files other.d expected.d
- $UNCACHED_COMPILE -c -Wp,-MD,other.d test.c -o reference_test.o
+ $REAL_COMPILER -c -Wp,-MD,other.d test.c -o reference_test.o
expect_equal_object_files reference_test.o test.o
rm -f other.d
expect_stat 'cache miss' 1
expect_equal_files other.d expected_mmd.d
- $UNCACHED_COMPILE -c -Wp,-MMD,other.d test.c -o reference_test.o
+ $REAL_COMPILER -c -Wp,-MMD,other.d test.c -o reference_test.o
expect_equal_object_files reference_test.o test.o
rm -f other.d
expect_stat 'cache miss' 1
expect_equal_files test.d expected.d
- $UNCACHED_COMPILE -c -MD test.c -o reference_test.o
+ $REAL_COMPILER -c -MD test.c -o reference_test.o
expect_equal_object_files reference_test.o test.o
rm -f test.d
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 1
expect_equal_files test.d expected.d
- $UNCACHED_COMPILE -c -MD test.c -o reference_test.o
+ $REAL_COMPILER -c -MD test.c -o reference_test.o
expect_equal_object_files reference_test.o test.o
rm -f test.d
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 1
expect_equal_files other.d expected.d
- $UNCACHED_COMPILE -c -MD -MF other.d test.c -o reference_test.o
+ $REAL_COMPILER -c -MD -MF other.d test.c -o reference_test.o
expect_equal_object_files reference_test.o test.o
rm -f other.d
SUITE_pch_PROBE() {
touch pch.h
- if ! $UNCACHED_COMPILE $SYSROOT -fpch-preprocess pch.h 2>/dev/null \
+ if ! $REAL_COMPILER $SYSROOT -fpch-preprocess pch.h 2>/dev/null \
|| [ ! -f pch.h.gch ]; then
echo "compiler ($($COMPILER --version | head -1)) doesn't support precompiled headers"
fi
# -------------------------------------------------------------------------
TEST "Use .gch, no -fpch-preprocess, #include"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, no -fpch-preprocess, -include, no sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, no -fpch-preprocess, -include, sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, -fpch-preprocess, #include, no sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, -fpch-preprocess, #include, sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, -fpch-preprocess, #include, file changed"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, preprocessor mode"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
# -------------------------------------------------------------------------
TEST "Use .gch, preprocessor mode, file changed"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
rm pch.h
expect_stat 'cache hit (preprocessed)' 0
expect_stat 'cache miss' 2
- $UNCACHED_COMPILE $SYSROOT -c -include pch2.h pch2.c
+ $REAL_COMPILER $SYSROOT -c -include pch2.h pch2.c
if [ ! -f pch2.o ]; then
test_failed "pch.o missing"
fi
# -------------------------------------------------------------------------
TEST "Use .gch, no -fpch-preprocess, -include, no sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
$CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c 2>/dev/null
# -------------------------------------------------------------------------
TEST "Use .gch, no -fpch-preprocess, -include, sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c
# -------------------------------------------------------------------------
TEST "Use .gch, -fpch-preprocess, -include, file changed"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c
# -------------------------------------------------------------------------
TEST "Use .gch, preprocessor mode"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c
# -------------------------------------------------------------------------
TEST "Use .gch, preprocessor mode, file changed"
- $UNCACHED_COMPILE $SYSROOT -c pch.h
+ $REAL_COMPILER $SYSROOT -c pch.h
backdate pch.h.gch
CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -fpch-preprocess pch.c
# -------------------------------------------------------------------------
TEST "Use .pth, no -fpch-preprocess, -include, no sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h -o pch.h.pth
+ $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth
backdate pch.h.pth
$CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c
# -------------------------------------------------------------------------
TEST "Use .pth, no -fpch-preprocess, -include, sloppiness"
- $UNCACHED_COMPILE $SYSROOT -c pch.h -o pch.h.pth
+ $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth
backdate pch.h.pth
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h pch2.c
# -------------------------------------------------------------------------
TEST "Use .pth, -fpch-preprocess, -include, file changed"
- $UNCACHED_COMPILE $SYSROOT -c pch.h -o pch.h.pth
+ $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth
backdate pch.h.pth
CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c
# -------------------------------------------------------------------------
TEST "Use .pth, preprocessor mode"
- $UNCACHED_COMPILE $SYSROOT -c pch.h -o pch.h.pth
+ $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth
backdate pch.h.pth
CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c
# -------------------------------------------------------------------------
TEST "Use .pth, preprocessor mode, file changed"
- $UNCACHED_COMPILE $SYSROOT -c pch.h -o pch.h.pth
+ $REAL_COMPILER $SYSROOT -c pch.h -o pch.h.pth
backdate pch.h.pth
CCACHE_NODIRECT=1 CCACHE_SLOPPINESS="$DEFAULT_SLOPPINESS pch_defines time_macros" $CCACHE_COMPILE $SYSROOT -c -include pch.h -fpch-preprocess pch.c
SUITE_input_charset_PROBE() {
touch test.c
- if ! $UNCACHED_COMPILE -c -finput-charset=latin1 test.c >/dev/null 2>&1; then
+ if ! $REAL_COMPILER -c -finput-charset=latin1 test.c >/dev/null 2>&1; then
echo "compiler doesn't support -finput-charset"
fi
}
input_charset
"
-compiler_location=$(which $(echo "$COMPILER" | awk '{print $1}'))
-if [ "$compiler_location" = "$COMPILER" ]; then
+REAL_COMPILER=$(find_compiler $COMPILER)
+if [ "$REAL_COMPILER" = "$COMPILER" ]; then
echo "Compiler: $COMPILER"
else
- echo "Compiler: $COMPILER ($compiler_location)"
+ echo "Compiler: $COMPILER ($REAL_COMPILER)"
fi
echo "Compiler version: $($COMPILER --version | head -n 1)"
echo