]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Improve fix in #400 to handle more cases
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 1 May 2019 12:51:45 +0000 (14:51 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 1 May 2019 12:51:45 +0000 (14:51 +0200)
The dependency file name can come from e.g. DEPENDENCIES_OUTPUT as well,
so hash information about a /dev/null .d file after the argument
processing loop instead.

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

index 2d2a96eb480798e9399d74b3805d92eeefe3a382..251783acb9f6ba364430418b0afc913e059b399e 100644 (file)
@@ -2049,9 +2049,6 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
                                                // Next argument is dependency name, so skip it.
                                                i++;
                                        }
-                               } else {
-                                       // Hash that we don't have a .d file.
-                                       hash_string(hash, output_dep);
                                }
                                continue;
                        }
@@ -2112,6 +2109,12 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
                }
        }
 
+       // Make results with dependency file /dev/null different from those without
+       // it.
+       if (generating_dependencies && str_eq(output_dep, "/dev/null")) {
+               hash_delimiter(hash, "/dev/null dependency file");
+       }
+
        if (!found_ccbin && str_eq(actual_language, "cuda")) {
                hash_nvcc_host_compiler(hash, NULL, NULL);
        }
index 4eb9bf6b5fcb58b39c5b65ca5459c69a7a19f5b4..ad5b490d585442cee93471511cca35a14d23c3cd 100644 (file)
@@ -139,4 +139,17 @@ SUITE_direct_gcc() {
     expect_stat 'cache miss' 1
     expect_equal_files different_name.d expected_sunpro_dependencies_target.d
     expect_equal_object_files reference_test.o test.o
+
+    # -------------------------------------------------------------------------
+    TEST "DEPENDENCIES_OUTPUT environment variable set to /dev/null"
+
+    DEPENDENCIES_OUTPUT="/dev/null" $CCACHE_COMPILE -c test.c
+    expect_stat 'cache hit (direct)' 0
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+
+    DEPENDENCIES_OUTPUT="other.d" $CCACHE_COMPILE -c test.c
+    expect_stat 'cache hit (direct)' 0
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 2
 }