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 elif $HOST_OS_FREEBSD; then 27 objdump -W $1 28 else 29 objdump -g $1 30 fi 31} 32 33grep_cmd() { 34 if $HOST_OS_APPLE; then 35 grep "( \"$1\" )" 36 else 37 grep ": $1[[:space:]]*$" 38 fi 39} 40 41SUITE_debug_prefix_map() { 42 # ------------------------------------------------------------------------- 43 TEST "Mapping of debug info CWD" 44 45 cd dir1 46 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o 47 expect_stat 'cache hit (direct)' 0 48 expect_stat 'cache hit (preprocessed)' 0 49 expect_stat 'cache miss' 1 50 expect_stat 'files in cache' 2 51 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 52 test_failed "Source dir (`pwd`) found in test.o" 53 fi 54 55 cd ../dir2 56 CCACHE_BASEDIR=`pwd` $CCACHE_COMPILE -I`pwd`/include -g -fdebug-prefix-map=`pwd`=dir -c `pwd`/src/test.c -o `pwd`/test.o 57 expect_stat 'cache hit (direct)' 1 58 expect_stat 'cache hit (preprocessed)' 0 59 expect_stat 'cache miss' 1 60 expect_stat 'files in cache' 2 61 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 62 test_failed "Source dir (`pwd`) found in test.o" 63 fi 64 65 # ------------------------------------------------------------------------- 66 TEST "Multiple -fdebug-prefix-map" 67 68 cd dir1 69 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 70 expect_stat 'cache hit (direct)' 0 71 expect_stat 'cache hit (preprocessed)' 0 72 expect_stat 'cache miss' 1 73 expect_stat 'files in cache' 2 74 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 75 test_failed "Source dir (`pwd`) found in test.o" 76 fi 77 if ! objdump_cmd test.o | grep_cmd "name" >/dev/null 2>&1; then 78 test_failed "Relocation (name) not found in test.o" 79 fi 80 81 cd ../dir2 82 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 83 expect_stat 'cache hit (direct)' 1 84 expect_stat 'cache hit (preprocessed)' 0 85 expect_stat 'cache miss' 1 86 expect_stat 'files in cache' 2 87 if objdump_cmd test.o | grep_cmd "`pwd`" >/dev/null 2>&1; then 88 test_failed "Source dir (`pwd`) found in test.o" 89 fi 90} 91