Skip to content

Commit 3e49ada

Browse files
committed
Auto merge of #47035 - acfoltzer:dep-info-tweak, r=alexcrichton
Remove dep-info files as targets in themselves If you ask `rustc` to `--emit dep-info`, the resulting dependency file contains a rule for producing the dependency file itself. This differs from the output of `gcc -MD` or `clang -MD`, which only includes dependency rules for the object files produced. Tools like Ninja often consume and delete dependency files as soon as they’re produced for performance reasons, particularly on Windows. In the case of `rustc` output, though, the recently-deleted dependency file is cached by Ninja as a target, and therefore triggers a rebuild every time. This very small patch removes the dep-info file from the list of output filenames, so it matches the behavior of gcc and clang.
2 parents da569fa + 8c09d29 commit 3e49ada

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/librustc/session/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12361236
overriding the default for the current target"),
12371237
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
12381238
"generate human-readable, predictable names for codegen units"),
1239+
dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED],
1240+
"in dep-info output, omit targets for tracking dependencies of the dep-info files \
1241+
themselves"),
12391242
}
12401243

12411244
pub fn default_lib_output() -> CrateType {

src/librustc_driver/driver.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,9 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) {
11621162
out_filenames.push(p);
11631163
}
11641164
}
1165+
OutputType::DepInfo if sess.opts.debugging_opts.dep_info_omit_d_target => {
1166+
// Don't add the dep-info output when omitting it from dep-info targets
1167+
}
11651168
_ => {
11661169
out_filenames.push(file);
11671170
}

0 commit comments

Comments
 (0)