From: Anders Björklund Date: Wed, 27 Jan 2016 21:08:23 +0000 (+0100) Subject: Only hash the cwd dir when generating debuginfo X-Git-Tag: v3.3~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2ade51e84fb2eca97be900f1b81624ffe650233;p=thirdparty%2Fccache.git Only hash the cwd dir when generating debuginfo Some distributions, like Fedora, enable CACHE_HASHDIR *globally* ! This and -fdebug-prefix-map will allow using CCACHE_BASEDIR again. --- diff --git a/MANUAL.txt b/MANUAL.txt index aae6d2aeb..d8791f255 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -376,7 +376,7 @@ WRAPPERS>>. working directory in the debug info set incorrectly. This option is off by default as the incorrect setting of this debug info rarely causes problems. If you strike problems with GDB not using the correct directory then enable - this option. + this option. The option *only* applies when generating debug info (-g). *ignore_headers_in_manifest* (*CCACHE_IGNOREHEADERS*):: diff --git a/ccache.c b/ccache.c index c9d87dd71..22df9c0b5 100644 --- a/ccache.c +++ b/ccache.c @@ -183,6 +183,9 @@ static char **ignore_headers; /* Size of headers to ignore list */ static size_t ignore_headers_len; +/* is gcc being asked to output debug info? */ +static bool generating_debuginfo; + /* is gcc being asked to output dependencies? */ static bool generating_dependencies; @@ -1489,7 +1492,7 @@ calculate_common_hash(struct args *args, struct mdfour *hash) free(p); /* Possibly hash the current working directory. */ - if (conf->hash_dir) { + if (generating_debuginfo && conf->hash_dir) { char *cwd = gnu_getcwd(); if (debug_prefix_map) { char *map = debug_prefix_map; @@ -2215,6 +2218,7 @@ cc_process_args(struct args *args, struct args **preprocessor_args, /* Debugging is handled specially, so that we know if we can strip line * number info. */ if (str_startswith(argv[i], "-g")) { + generating_debuginfo = true; args_add(stripped_args, argv[i]); if (conf->unify && !str_eq(argv[i], "-g0")) { cc_log("%s used; disabling unify mode", argv[i]); @@ -3059,6 +3063,7 @@ cc_reset(void) if (included_files) { hashtable_destroy(included_files, 1); included_files = NULL; } + generating_debuginfo = false; generating_dependencies = false; generating_coverage = false; profile_arcs = false; diff --git a/test.sh b/test.sh index e6d2cf52f..af5fa1772 100755 --- a/test.sh +++ b/test.sh @@ -294,16 +294,14 @@ base_tests() { checkstat 'files in cache' 4 testname="CCACHE_HASHDIR" - CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O + CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -g -O -O checkstat 'cache hit (preprocessed)' 5 checkstat 'cache miss' 5 - compare_object reference_test1.o test1.o - CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O + CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -g -O -O checkstat 'cache hit (preprocessed)' 6 checkstat 'cache miss' 5 checkstat 'files in cache' 5 - compare_object reference_test1.o test1.o testname="comments" echo '/* a silly comment */' > test1-comment.c