Skip to content

Commit 796264b

Browse files
incr.comp.: Add -Cincremental in addition to -Zincremental
1 parent 5a0dc2d commit 796264b

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/librustc/session/config.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10131013
"set the threshold for inlining a function (default: 225)"),
10141014
panic: Option<PanicStrategy> = (None, parse_panic_strategy,
10151015
[TRACKED], "panic strategy to compile crate with"),
1016+
incremental: Option<String> = (None, parse_opt_string, [UNTRACKED],
1017+
"enable incremental compilation"),
10161018
}
10171019

10181020
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
@@ -1663,7 +1665,24 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
16631665
early_error(error_format, "Value for codegen units must be a positive nonzero integer");
16641666
}
16651667

1666-
if cg.lto && debugging_opts.incremental.is_some() {
1668+
let incremental = match (&debugging_opts.incremental, &cg.incremental) {
1669+
(&Some(ref path1), &Some(ref path2)) => {
1670+
if path1 != path2 {
1671+
early_error(error_format,
1672+
&format!("conflicting paths for `-Z incremental` and \
1673+
`-C incremental` specified: {} versus {}",
1674+
path1,
1675+
path2));
1676+
} else {
1677+
Some(path1)
1678+
}
1679+
}
1680+
(&Some(ref path), &None) => Some(path),
1681+
(&None, &Some(ref path)) => Some(path),
1682+
(&None, &None) => None,
1683+
}.map(|m| PathBuf::from(m));
1684+
1685+
if cg.lto && incremental.is_some() {
16671686
early_error(error_format, "can't perform LTO when compiling incrementally");
16681687
}
16691688

@@ -1837,8 +1856,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
18371856

18381857
let crate_name = matches.opt_str("crate-name");
18391858

1840-
let incremental = debugging_opts.incremental.as_ref().map(|m| PathBuf::from(m));
1841-
18421859
(Options {
18431860
crate_types,
18441861
optimize: opt_level,
@@ -2581,6 +2598,9 @@ mod tests {
25812598
opts.cg.save_temps = true;
25822599
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
25832600

2601+
opts.cg.incremental = Some(String::from("abc"));
2602+
assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
2603+
25842604

25852605
// Make sure changing a [TRACKED] option changes the hash
25862606
opts = reference.clone();

src/librustc_trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(
10251025

10261026
assert_symbols_are_distinct(tcx, items.iter());
10271027

1028-
let strategy = if tcx.sess.opts.debugging_opts.incremental.is_some() {
1028+
let strategy = if tcx.sess.opts.incremental.is_some() {
10291029
PartitioningStrategy::PerModule
10301030
} else {
10311031
PartitioningStrategy::FixedUnitCount(tcx.sess.codegen_units())

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ impl<'test> TestCx<'test> {
15061506

15071507
if let Some(ref incremental_dir) = self.props.incremental_dir {
15081508
rustc.args(&[
1509-
"-Z",
1509+
"-C",
15101510
&format!("incremental={}", incremental_dir.display()),
15111511
]);
15121512
rustc.args(&["-Z", "incremental-verify-ich"]);

0 commit comments

Comments
 (0)