]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Support GCC 9’s -gz=[type] option
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 12 Sep 2019 18:50:46 +0000 (20:50 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 12 Sep 2019 18:50:46 +0000 (20:50 +0200)
-gz[=type] neither disables nor enables generation of debug info, so
don’t enable the fallback behavior of hashing the current directory when
seeing -gz[=type] alone.

Closes #464.

src/ccache.c
test/suites/base.bash

index 6204ce2124f6b46310cea5f8c6fbb65ff94e4d02..f56445beef24bf4ca2a768e45b634d9513ae8c56 100644 (file)
@@ -2778,6 +2778,11 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                                continue;
                        }
 
+                       if (str_startswith(argv[i], "-gz")) {
+                               // -gz[=type] neither disables nor enables debug info.
+                               continue;
+                       }
+
                        char last_char = argv[i][strlen(argv[i]) - 1];
                        if (last_char == '0') {
                                // "-g0", "-ggdb0" or similar: All debug information disabled.
index 6fb76d84066747e90b44ae7a1d24d2f2dddf9fed..5e9cd4d0c430c04ac1285759d830c161d12611a8 100644 (file)
@@ -370,6 +370,50 @@ base_tests() {
     expect_stat 'cache hit (preprocessed)' 2
     expect_stat 'cache miss' 1
 
+    # -------------------------------------------------------------------------
+    TEST "Directory is not hashed if using -gz"
+
+    if $REAL_COMPILER -c test1.c -gz -o /dev/null 2>/dev/null; then
+        mkdir dir1 dir2
+        cp test1.c dir1
+        cp test1.c dir2
+
+        cd dir1
+        $CCACHE_COMPILE -c test1.c -gz
+        expect_stat 'cache hit (preprocessed)' 0
+        expect_stat 'cache miss' 1
+        $CCACHE_COMPILE -c test1.c -gz
+        expect_stat 'cache hit (preprocessed)' 1
+        expect_stat 'cache miss' 1
+
+        cd ../dir2
+        $CCACHE_COMPILE -c test1.c -gz
+        expect_stat 'cache hit (preprocessed)' 2
+        expect_stat 'cache miss' 1
+    fi
+
+    # -------------------------------------------------------------------------
+    TEST "Directory is not hashed if using -gz=zlib"
+
+    if $REAL_COMPILER -c test1.c -gz=zlib -o /dev/null 2>/dev/null; then
+        mkdir dir1 dir2
+        cp test1.c dir1
+        cp test1.c dir2
+
+        cd dir1
+        $CCACHE_COMPILE -c test1.c -gz=zlib
+        expect_stat 'cache hit (preprocessed)' 0
+        expect_stat 'cache miss' 1
+        $CCACHE_COMPILE -c test1.c -gz=zlib
+        expect_stat 'cache hit (preprocessed)' 1
+        expect_stat 'cache miss' 1
+
+        cd ../dir2
+        $CCACHE_COMPILE -c test1.c -gz=zlib
+        expect_stat 'cache hit (preprocessed)' 2
+        expect_stat 'cache miss' 1
+    fi
+
     # -------------------------------------------------------------------------
     TEST "CCACHE_NOHASHDIR"