Skip to content

Commit 57ffda6

Browse files
committed
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.
1 parent 5a02480 commit 57ffda6

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

src/librustc/session/config.rs

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

src/librustc_incremental/persist/load.rs

+13
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,24 @@ fn dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
250250
current_hash);
251251
continue;
252252
}
253+
254+
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
255+
println!("node {:?} is dirty as hash is {:?} was {:?}",
256+
dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
257+
current_hash,
258+
hash.hash);
259+
}
260+
253261
debug!("initial_dirty_nodes: {:?} is dirty as hash is {:?}, was {:?}",
254262
dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
255263
current_hash,
256264
hash.hash);
257265
} else {
266+
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
267+
println!("node {:?} is dirty as it was removed",
268+
hash.dep_node);
269+
}
270+
258271
debug!("initial_dirty_nodes: {:?} is dirty as it was removed",
259272
hash.dep_node);
260273
}

src/librustc_incremental/persist/save.rs

+15
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)