]> 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 19:26:27 +0000 (21:26 +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.

(cherry picked from commit cb7a05a772ce3dcec58da16d957420f36cb97f75)

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

index a9fb738b00a5696afc82291591663d4ebc1693c1..87599e7945bb00d3b8a0ccce7ea9b1cfe1562650 100644 (file)
@@ -2633,6 +2633,11 @@ cc_process_args(struct args* 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 34e8deb860ce69a2eb311c7606e0f90faecef80b..7fe30f46b8c1911457268a0170c4c0ce2eb3c855 100644 (file)
@@ -382,6 +382,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"