]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Revert "Bail out on “-MF /dev/null”"
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 1 May 2019 12:21:41 +0000 (14:21 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 1 May 2019 12:21:41 +0000 (14:21 +0200)
This reverts commit 253301e7ac56a9d2bed1f03a91ba73be102a0d42.

src/ccache.c
test/suites/depend.bash
test/suites/direct.bash

index 6d38c62dbcc47fb36eba81f5f6b98cf8c2898dfb..4b1aed0e9ca583487c96cbd268d3903a76b96f58 100644 (file)
@@ -1519,7 +1519,10 @@ to_cache(struct args *args, struct hash *depend_mode_hash)
                update_cached_result_globals(object_hash);
        }
 
-       if (generating_dependencies) {
+       bool produce_dep_file = generating_dependencies &&
+                               !str_eq(output_dep, "/dev/null");
+
+       if (produce_dep_file) {
                use_relative_paths_in_depfile(output_dep);
        }
 
@@ -1555,7 +1558,7 @@ to_cache(struct args *args, struct hash *depend_mode_hash)
        MTR_BEGIN("file", "file_put");
 
        copy_file_to_cache(output_obj, cached_obj);
-       if (generating_dependencies) {
+       if (produce_dep_file) {
                copy_file_to_cache(output_dep, cached_dep);
        }
        if (generating_coverage) {
@@ -2220,7 +2223,10 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
                        args_pop(args, 1);
                }
                if (generating_dependencies) {
-                       cc_log("Preprocessor created %s", output_dep);
+                       // Nothing is actually created with -MF /dev/null
+                       if (!str_eq(output_dep, "/dev/null")) {
+                               cc_log("Preprocessor created %s", output_dep);
+                       }
                }
        }
 
@@ -2268,7 +2274,8 @@ from_cache(enum fromcache_call_mode mode, bool put_object_in_manifest)
 
        // (If mode != FROMCACHE_DIRECT_MODE, the dependency file is created by gcc.)
        bool produce_dep_file =
-               generating_dependencies && mode == FROMCACHE_DIRECT_MODE;
+               generating_dependencies && mode == FROMCACHE_DIRECT_MODE &&
+               !str_eq(output_dep, "/dev/null");
 
        MTR_BEGIN("file", "file_get");
 
@@ -3222,12 +3229,6 @@ cc_process_args(struct args *args, struct args **preprocessor_args,
                }
        }
 
-       if (output_dep && str_eq(output_dep, "/dev/null")) {
-               cc_log("/dev/null is not supported as a dependency file target"),
-               stats_update(STATS_UNSUPPORTED_OPTION);
-               failed();
-       }
-
        if (found_S_opt) {
                // Even if -gsplit-dwarf is given, the .dwo file is not generated when -S
                // is also given.
@@ -3843,7 +3844,8 @@ ccache(int argc, char *argv[])
        MTR_END("main", "process_args");
 
        if (conf->depend_mode
-           && (!generating_dependencies || !conf->run_second_cpp || conf->unify)) {
+           && (!generating_dependencies || str_eq(output_dep, "/dev/null") ||
+               !conf->run_second_cpp || conf->unify)) {
                cc_log("Disabling depend mode");
                conf->depend_mode = false;
        }
index ff622cbf1aa4e2c4f551f0504d02a84efe6a8504..a13f84260d41a10c2ac23380d1a14fedc49a3627 100644 (file)
@@ -114,8 +114,14 @@ SUITE_depend() {
     CCACHE_DEPEND=1 $CCACHE_COMPILE -MP -MMD -MF /dev/null -c test.c
     expect_stat 'cache hit (direct)' 0
     expect_stat 'cache hit (preprocessed)' 0
-    expect_stat 'cache miss' 0
-    expect_stat 'unsupported compiler option' 1
+    expect_stat 'cache miss' 1
+    expect_stat 'files in cache' 2 # .o + .manifest
+
+    CCACHE_DEPEND=1 $CCACHE_COMPILE -MP -MMD -MF /dev/null -c test.c
+    expect_stat 'cache hit (direct)' 1
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+    expect_stat 'files in cache' 2
 
     # -------------------------------------------------------------------------
     TEST "No explicit dependency file"
index 201ad2433005ff23d71a791f5c09779b57ebdb6c..f721e7589d4c6f908dff876c650b6724c778633b 100644 (file)
@@ -439,13 +439,19 @@ EOF
     rm -f third_name.d
 
     # -------------------------------------------------------------------------
-    TEST "-MF /dev/null"
+    TEST "MF /dev/null"
 
     $CCACHE_COMPILE -c -MD -MF /dev/null test.c
     expect_stat 'cache hit (direct)' 0
     expect_stat 'cache hit (preprocessed)' 0
-    expect_stat 'cache miss' 0
-    expect_stat 'unsupported compiler option' 1
+    expect_stat 'cache miss' 1
+    expect_stat 'files in cache' 2 # .o + .manifest
+
+    $CCACHE_COMPILE -c -MD -MF /dev/null test.c
+    expect_stat 'cache hit (direct)' 1
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+    expect_stat 'files in cache' 2
 
     # -------------------------------------------------------------------------
     TEST "Missing .d file"