]> git.lizzy.rs Git - rust.git/commitdiff
add a `-Z incremental-dump-hash` flag
authorNiko Matsakis <niko@alum.mit.edu>
Thu, 1 Dec 2016 17:29:28 +0000 (12:29 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Thu, 1 Dec 2016 17:29:28 +0000 (12:29 -0500)
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.

src/librustc/session/config.rs
src/librustc_incremental/persist/load.rs
src/librustc_incremental/persist/save.rs

index 26dafed7019ed7b9e25c8f6732fb222636aa4ab6..0052fe25b05f0dc061c5857d862c8bee8205a739 100644 (file)
@@ -885,6 +885,8 @@ fn parse_panic_strategy(slot: &mut Option<PanicStrategy>, v: Option<&str>) -> bo
           "enable incremental compilation (experimental)"),
     incremental_info: bool = (false, parse_bool, [UNTRACKED],
         "print high-level information about incremental reuse (or the lack thereof)"),
+    incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED],
+        "dump hash information in textual format to stdout"),
     dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
           "dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
     query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
index 12bf74c95116d508b197daf711a824071bcd511a..ead353512c7ef38dd9900facfa10fe11fec7a565 100644 (file)
@@ -250,11 +250,24 @@ fn dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                    current_hash);
                 continue;
             }
+
+            if tcx.sess.opts.debugging_opts.incremental_dump_hash {
+                println!("node {:?} is dirty as hash is {:?} was {:?}",
+                         dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
+                         current_hash,
+                         hash.hash);
+            }
+
             debug!("initial_dirty_nodes: {:?} is dirty as hash is {:?}, was {:?}",
                    dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
                    current_hash,
                    hash.hash);
         } else {
+            if tcx.sess.opts.debugging_opts.incremental_dump_hash {
+                println!("node {:?} is dirty as it was removed",
+                         hash.dep_node);
+            }
+
             debug!("initial_dirty_nodes: {:?} is dirty as it was removed",
                    hash.dep_node);
         }
index 05e21aa19b1b8870c6841a3f5af68e4ffc879344..1ce4bf7f033417735a3fe09c160ee06a71177a8e 100644 (file)
@@ -159,6 +159,12 @@ pub fn encode_dep_graph(preds: &Predecessors,
         }
     }
 
+    if tcx.sess.opts.debugging_opts.incremental_dump_hash {
+        for (dep_node, hash) in &preds.hashes {
+            println!("HIR hash for {:?} is {}", dep_node, hash);
+        }
+    }
+
     // Create the serialized dep-graph.
     let graph = SerializedDepGraph {
         edges: edges,
@@ -248,6 +254,15 @@ pub fn encode_metadata_hashes(tcx: TyCtxt,
         let hash = state.finish();
 
         debug!("save: metadata hash for {:?} is {}", def_id, hash);
+
+        if tcx.sess.opts.debugging_opts.incremental_dump_hash {
+            println!("metadata hash for {:?} is {}", def_id, hash);
+            for dep_node in sources {
+                println!("metadata hash for {:?} depends on {:?} with hash {}",
+                         def_id, dep_node, preds.hashes[dep_node]);
+            }
+        }
+
         serialized_hashes.hashes.push(SerializedMetadataHash {
             def_index: def_id.index,
             hash: hash,