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);
}
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) {
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);
+ }
}
}
// (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");
}
}
- 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.
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;
}
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"
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"