about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2016-11-30 17:33:52 -0500
committerMichael Woerister <michaelwoerister@posteo>2016-11-30 17:33:52 -0500
commit29a6ffa4010d965a6c587c9ffd1ce88bbea164c9 (patch)
tree615d76eac49c78cca5e3d39a99d3ace705ec727e
parent5db4826410b4ffcc0e4cb45566a0411a0858b6bf (diff)
downloadrust-29a6ffa4010d965a6c587c9ffd1ce88bbea164c9.tar.gz
rust-29a6ffa4010d965a6c587c9ffd1ce88bbea164c9.zip
incr.comp.: Add more output to -Z incremental-info.
-rw-r--r--src/librustc_incremental/persist/file_format.rs16
-rw-r--r--src/librustc_incremental/persist/fs.rs4
-rw-r--r--src/librustc_incremental/persist/hash.rs2
-rw-r--r--src/librustc_incremental/persist/load.rs32
-rw-r--r--src/librustc_trans/base.rs5
5 files changed, 44 insertions, 15 deletions
diff --git a/src/librustc_incremental/persist/file_format.rs b/src/librustc_incremental/persist/file_format.rs
index 7c2b69e762b..b67caa6750a 100644
--- a/src/librustc_incremental/persist/file_format.rs
+++ b/src/librustc_incremental/persist/file_format.rs
@@ -24,6 +24,7 @@ use std::path::Path;
 use std::fs::File;
 use std::env;
 
+use rustc::session::Session;
 use rustc::session::config::nightly_options;
 
 /// The first few bytes of files generated by incremental compilation
@@ -59,7 +60,7 @@ pub fn write_file_header<W: io::Write>(stream: &mut W) -> io::Result<()> {
 ///   incompatible version of the compiler.
 /// - Returns `Err(..)` if some kind of IO error occurred while reading the
 ///   file.
-pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
+pub fn read_file(sess: &Session, path: &Path) -> io::Result<Option<Vec<u8>>> {
     if !path.exists() {
         return Ok(None);
     }
@@ -72,6 +73,7 @@ pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
         let mut file_magic = [0u8; 4];
         file.read_exact(&mut file_magic)?;
         if file_magic != FILE_MAGIC {
+            report_format_mismatch(sess, path, "Wrong FILE_MAGIC");
             return Ok(None)
         }
     }
@@ -85,6 +87,7 @@ pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
                                     ((header_format_version[1] as u16) << 8);
 
         if header_format_version != HEADER_FORMAT_VERSION {
+            report_format_mismatch(sess, path, "Wrong HEADER_FORMAT_VERSION");
             return Ok(None)
         }
     }
@@ -99,6 +102,7 @@ pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
         file.read_exact(&mut buffer[..])?;
 
         if &buffer[..] != rustc_version().as_bytes() {
+            report_format_mismatch(sess, path, "Different compiler version");
             return Ok(None);
         }
     }
@@ -109,6 +113,16 @@ pub fn read_file(path: &Path) -> io::Result<Option<Vec<u8>>> {
     Ok(Some(data))
 }
 
+fn report_format_mismatch(sess: &Session, file: &Path, message: &str) {
+    debug!("read_file: {}", message);
+
+    if sess.opts.debugging_opts.incremental_info {
+        println!("incremental: ignoring cache artifact `{}`: {}",
+                 file.file_name().unwrap().to_string_lossy(),
+                 message);
+    }
+}
+
 fn rustc_version() -> String {
     if nightly_options::is_nightly_build() {
         if let Some(val) = env::var_os("RUSTC_FORCE_INCR_COMP_ARTIFACT_HEADER") {
diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs
index 26181dbaf50..2ad37e98c70 100644
--- a/src/librustc_incremental/persist/fs.rs
+++ b/src/librustc_incremental/persist/fs.rs
@@ -435,8 +435,8 @@ fn copy_files(target_dir: &Path,
     }
 
     if print_stats_on_success {
-        println!("incr. comp. session directory: {} files hard-linked", files_linked);
-        println!("incr. comp. session directory: {} files copied", files_copied);
+        println!("incremental: session directory: {} files hard-linked", files_linked);
+        println!("incremental: session directory: {} files copied", files_copied);
     }
 
     Ok(files_linked > 0 || files_copied == 0)
diff --git a/src/librustc_incremental/persist/hash.rs b/src/librustc_incremental/persist/hash.rs
index 562efa4b0d2..e5203ea02b4 100644
--- a/src/librustc_incremental/persist/hash.rs
+++ b/src/librustc_incremental/persist/hash.rs
@@ -156,7 +156,7 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
 
             let hashes_file_path = metadata_hash_import_path(&session_dir);
 
-            match file_format::read_file(&hashes_file_path)
+            match file_format::read_file(self.tcx.sess, &hashes_file_path)
             {
                 Ok(Some(data)) => {
                     match self.load_from_data(cnum, &data, svh) {
diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs
index 12bf74c9511..ec7e0bf2cf7 100644
--- a/src/librustc_incremental/persist/load.rs
+++ b/src/librustc_incremental/persist/load.rs
@@ -93,7 +93,7 @@ fn load_dep_graph_if_exists<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 fn load_data(sess: &Session, path: &Path) -> Option<Vec<u8>> {
-    match file_format::read_file(path) {
+    match file_format::read_file(sess, path) {
         Ok(Some(data)) => return Some(data),
         Ok(None) => {
             // The file either didn't exist or was produced by an incompatible
@@ -132,6 +132,10 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let prev_commandline_args_hash = u64::decode(&mut dep_graph_decoder)?;
 
     if prev_commandline_args_hash != tcx.sess.opts.dep_tracking_hash() {
+        if tcx.sess.opts.debugging_opts.incremental_info {
+            println!("incremental: completely ignoring cache because of \
+                      differing commandline arguments");
+        }
         // We can't reuse the cache, purge it.
         debug!("decode_dep_graph: differing commandline arg hashes");
         for swp in work_products {
@@ -192,7 +196,8 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 if tcx.sess.opts.debugging_opts.incremental_info {
                     // It'd be nice to pretty-print these paths better than just
                     // using the `Debug` impls, but wev.
-                    println!("module {:?} is dirty because {:?} changed or was removed",
+                    println!("incremental: module {:?} is dirty because {:?} \
+                              changed or was removed",
                              target_node,
                              raw_source_node.map_def(|&index| {
                                  Some(directory.def_path_string(tcx, index))
@@ -277,14 +282,19 @@ fn reconcile_work_products<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             debug!("reconcile_work_products: dep-node for {:?} is dirty", swp);
             delete_dirty_work_product(tcx, swp);
         } else {
-            let all_files_exist =
-                swp.work_product
-                   .saved_files
-                   .iter()
-                   .all(|&(_, ref file_name)| {
-                       let path = in_incr_comp_dir_sess(tcx.sess, &file_name);
-                       path.exists()
-                   });
+            let mut all_files_exist = true;
+            for &(_, ref file_name) in swp.work_product.saved_files.iter() {
+                let path = in_incr_comp_dir_sess(tcx.sess, file_name);
+                if !path.exists() {
+                    all_files_exist = false;
+
+                    if tcx.sess.opts.debugging_opts.incremental_info {
+                        println!("incremental: could not find file for up-to-date work product: {}",
+                                 path.display());
+                    }
+                }
+            }
+
             if all_files_exist {
                 debug!("reconcile_work_products: all files for {:?} exist", swp);
                 tcx.dep_graph.insert_previous_work_product(&swp.id, swp.work_product);
@@ -331,7 +341,7 @@ fn load_prev_metadata_hashes(tcx: TyCtxt,
 
     debug!("load_prev_metadata_hashes() - File: {}", file_path.display());
 
-    let data = match file_format::read_file(&file_path) {
+    let data = match file_format::read_file(tcx.sess, &file_path) {
         Ok(Some(data)) => data,
         Ok(None) => {
             debug!("load_prev_metadata_hashes() - File produced by incompatible \
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs
index f1126e6fd25..259ef2a780c 100644
--- a/src/librustc_trans/base.rs
+++ b/src/librustc_trans/base.rs
@@ -1981,6 +1981,11 @@ fn trans_reuse_previous_work_products(tcx: TyCtxt,
                     debug!("trans_reuse_previous_work_products: reusing {:?}", work_product);
                     return Some(work_product);
                 } else {
+                    if tcx.sess.opts.debugging_opts.incremental_info {
+                        println!("incremental: CGU `{}` invalidated because of \
+                                  changed partitioning hash.",
+                                  cgu.name());
+                    }
                     debug!("trans_reuse_previous_work_products: \
                             not reusing {:?} because hash changed to {:?}",
                            work_product, hash);