]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Only hash the cwd dir when generating debuginfo
authorAnders Björklund <anders@itension.se>
Wed, 27 Jan 2016 21:08:23 +0000 (22:08 +0100)
committerAnders Björklund <anders@itension.se>
Mon, 8 Feb 2016 19:14:23 +0000 (20:14 +0100)
Some distributions, like Fedora, enable CACHE_HASHDIR *globally* !
This and -fdebug-prefix-map will allow using CCACHE_BASEDIR again.

MANUAL.txt
ccache.c
test.sh

index aae6d2aeb2c23b5e2f32737b429359d59201d044..d8791f255aac542dd3855aba68b5a1b714ad29b7 100644 (file)
@@ -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*)::
 
index c9d87dd71b86910b6b4fea7276ba778eaff920b4..22df9c0b5cbb7d65ec8345857b0382ad64ec857f 100644 (file)
--- 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 e6d2cf52feba8d4e64829be727ddb4340dfc889f..af5fa17720911a057fa8305d0c669f2d34ab2a31 100755 (executable)
--- 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