Skip to content

Commit d6281fa

Browse files
authored
Rollup merge of #38113 - nikomatsakis:incremental-dump-hash, r=michaelwoerister
add a `-Z incremental-dump-hash` flag This causes us to dump a bunch of has information to stdout that can be useful in tracking down incremental compilation invalidations, particularly across crates.
2 parents 3231641 + 57ffda6 commit d6281fa

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/librustc/session/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
886886
"enable incremental compilation (experimental)"),
887887
incremental_info: bool = (false, parse_bool, [UNTRACKED],
888888
"print high-level information about incremental reuse (or the lack thereof)"),
889+
incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED],
890+
"dump hash information in textual format to stdout"),
889891
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
890892
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
891893
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],

src/librustc_incremental/persist/load.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,24 @@ fn dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
255255
current_hash);
256256
continue;
257257
}
258+
259+
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
260+
println!("node {:?} is dirty as hash is {:?} was {:?}",
261+
dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
262+
current_hash,
263+
hash.hash);
264+
}
265+
258266
debug!("initial_dirty_nodes: {:?} is dirty as hash is {:?}, was {:?}",
259267
dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
260268
current_hash,
261269
hash.hash);
262270
} else {
271+
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
272+
println!("node {:?} is dirty as it was removed",
273+
hash.dep_node);
274+
}
275+
263276
debug!("initial_dirty_nodes: {:?} is dirty as it was removed",
264277
hash.dep_node);
265278
}

src/librustc_incremental/persist/save.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ pub fn encode_dep_graph(preds: &Predecessors,
159159
}
160160
}
161161

162+
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
163+
for (dep_node, hash) in &preds.hashes {
164+
println!("HIR hash for {:?} is {}", dep_node, hash);
165+
}
166+
}
167+
162168
// Create the serialized dep-graph.
163169
let graph = SerializedDepGraph {
164170
edges: edges,
@@ -248,6 +254,15 @@ pub fn encode_metadata_hashes(tcx: TyCtxt,
248254
let hash = state.finish();
249255

250256
debug!("save: metadata hash for {:?} is {}", def_id, hash);
257+
258+
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
259+
println!("metadata hash for {:?} is {}", def_id, hash);
260+
for dep_node in sources {
261+
println!("metadata hash for {:?} depends on {:?} with hash {}",
262+
def_id, dep_node, preds.hashes[dep_node]);
263+
}
264+
}
265+
251266
serialized_hashes.hashes.push(SerializedMetadataHash {
252267
def_index: def_id.index,
253268
hash: hash,

0 commit comments

Comments
 (0)