]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #46751 - michaelwoerister:c-incremental, r=alexcrichton
authorkennytm <kennytm@gmail.com>
Wed, 20 Dec 2017 13:21:54 +0000 (21:21 +0800)
committerGitHub <noreply@github.com>
Wed, 20 Dec 2017 13:21:54 +0000 (21:21 +0800)
incr.comp.: Add `-C incremental` in addition to `-Z incremental`

This PR adds a stable commandline option for invoking incremental compilation.

r? @alexcrichton

src/librustc/session/config.rs
src/librustc_trans/base.rs
src/tools/compiletest/src/runtest.rs

index 009fb61984638fa139752381b5d2959006337348..a1cf38ae336d21243af97ee5203717e033bd0ceb 100644 (file)
@@ -1013,6 +1013,8 @@ fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) ->
         "set the threshold for inlining a function (default: 225)"),
     panic: Option<PanicStrategy> = (None, parse_panic_strategy,
         [TRACKED], "panic strategy to compile crate with"),
+    incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
+          "enable incremental compilation"),
 }
 
 options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
@@ -1663,7 +1665,24 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
         early_error(error_format, "Value for codegen units must be a positive nonzero integer");
     }
 
-    if cg.lto && debugging_opts.incremental.is_some() {
+    let incremental = match (&debugging_opts.incremental, &cg.incremental) {
+        (&Some(ref path1), &Some(ref path2)) => {
+            if path1 != path2 {
+                early_error(error_format,
+                    &format!("conflicting paths for `-Z incremental` and \
+                              `-C incremental` specified: {} versus {}",
+                              path1,
+                              path2));
+            } else {
+                Some(path1)
+            }
+        }
+        (&Some(ref path), &None) => Some(path),
+        (&None, &Some(ref path)) => Some(path),
+        (&None, &None) => None,
+    }.map(|m| PathBuf::from(m));
+
+    if cg.lto && incremental.is_some() {
         early_error(error_format, "can't perform LTO when compiling incrementally");
     }
 
@@ -1837,8 +1856,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
 
     let crate_name = matches.opt_str("crate-name");
 
-    let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));
-
     (Options {
         crate_types,
         optimize: opt_level,
@@ -2581,6 +2598,9 @@ fn test_codegen_options_tracking_hash() {
         opts.cg.save_temps = true;
         assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
 
+        opts.cg.incremental = Some(String::from("abc"));
+        assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
+
 
         // Make sure changing a [TRACKED] option changes the hash
         opts = reference.clone();
index 79b3d314e12ffa00b5708eac8a801216bd2db3ac..ea68925705f521cb598d823ddd8578e3311f928b 100644 (file)
@@ -1024,7 +1024,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
 
     assert_symbols_are_distinct(tcx, items.iter());
 
-    let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() {
+    let strategy = if tcx.sess.opts.incremental.is_some() {
         PartitioningStrategy::PerModule
     } else {
         PartitioningStrategy::FixedUnitCount(tcx.sess.codegen_units())
index 06e798554167b9637b591b8b5039a8cc9aed99a8..3aee88136a1ff1ab6488b68ea1521483d157dd04 100644 (file)
@@ -1506,7 +1506,7 @@ fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> C
 
         if let Some(ref incremental_dir) = self.props.incremental_dir {
             rustc.args(&[
-                "-Z",
+                "-C",
                 &format!("incremental={}", incremental_dir.display()),
             ]);
             rustc.args(&["-Z", "incremental-verify-ich"]);