1SUITE_debug_prefix_map_PROBE() { 2 touch test.c 3 if ! $REAL_COMPILER -c -fdebug-prefix-map=old=new test.c 2>/dev/null; then 4 echo "-fdebug-prefix-map not supported by compiler" 5 fi 6} 7 8SUITE_debug_prefix_map_SETUP() { 9 unset CCACHE_NODIRECT 10 11 mkdir -p dir1/src dir1/include 12 cat <<EOF >dir1/src/test.c 13#include <stdarg.h> 14#include <test.h> 15EOF 16 cat <<EOF >dir1/include/test.h 17int test; 18EOF 19 cp -r dir1 dir2 20 backdate dir1/include/test.h dir2/include/test.h 21} 22 23objdump_cmd() { 24 if $HOST_OS_APPLE; then 25 xcrun dwarfdump -r0 $1 26 else 27 objdump -W $1 28 fi 29} 30 31grep_cmd() { 32 if $HOST_OS_APPLE; then 33 grep "( \"$1\" )" 34 else 35 grep ": $1[[:space:]]*$" 36 fi 37} 38 39SUITE_debug_prefix_map() { 40 # ------------------------------------------------------------------------- 41 TEST "Mapping of debug info CWD" 42 43 cd dir1 44 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o 45 expect_stat 'cache hit (direct)' 0 46 expect_stat 'cache hit (preprocessed)' 0 47 expect_stat 'cache miss' 1 48 expect_stat 'files in cache' 2 49 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 50 test_failed "Source dir (`pwd`) found in test.o" 51 fi 52 53 cd ../dir2 54 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o 55 expect_stat 'cache hit (direct)' 1 56 expect_stat 'cache hit (preprocessed)' 0 57 expect_stat 'cache miss' 1 58 expect_stat 'files in cache' 2 59 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 60 test_failed "Source dir (`pwd`) found in test.o" 61 fi 62 63 # ------------------------------------------------------------------------- 64 TEST "Multiple -fdebug-prefix-map" 65 66 cd dir1 67 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=name -fdebug-prefix-map=foo=bar -c `pwd`/src/test.c -o `pwd`/test.o 68 expect_stat 'cache hit (direct)' 0 69 expect_stat 'cache hit (preprocessed)' 0 70 expect_stat 'cache miss' 1 71 expect_stat 'files in cache' 2 72 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 73 test_failed "Source dir (`pwd`) found in test.o" 74 fi 75 if ! objdump_cmd test.o | grep_cmd "name" >/dev/null 2>&1; then 76 test_failed "Relocation (name) not found in test.o" 77 fi 78 79 cd ../dir2 80 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=name -fdebug-prefix-map=foo=bar -c `pwd`/src/test.c -o `pwd`/test.o 81 expect_stat 'cache hit (direct)' 1 82 expect_stat 'cache hit (preprocessed)' 0 83 expect_stat 'cache miss' 1 84 expect_stat 'files in cache' 2 85 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 86 test_failed "Source dir (`pwd`) found in test.o" 87 fi 88} 89