From: Joel Rosdahl Date: Wed, 1 May 2019 12:21:41 +0000 (+0200) Subject: Revert "Bail out on “-MF /dev/null”" X-Git-Tag: v3.7.1~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a355200c37063dcbdf8e1eac441cf079b26b9c52;p=thirdparty%2Fccache.git Revert "Bail out on “-MF /dev/null”" This reverts commit 253301e7ac56a9d2bed1f03a91ba73be102a0d42. --- diff --git a/src/ccache.c b/src/ccache.c index 6d38c62db..4b1aed0e9 100644 --- a/src/ccache.c +++ b/src/ccache.c @@ -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; } diff --git a/test/suites/depend.bash b/test/suites/depend.bash index ff622cbf1..a13f84260 100644 --- a/test/suites/depend.bash +++ b/test/suites/depend.bash @@ -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" diff --git a/test/suites/direct.bash b/test/suites/direct.bash index 201ad2433..f721e7589 100644 --- a/test/suites/direct.bash +++ b/test/suites/direct.bash @@ -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"