@@ -1013,6 +1013,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
1013
1013
"set the threshold for inlining a function (default: 225)" ) ,
1014
1014
panic: Option <PanicStrategy > = ( None , parse_panic_strategy,
1015
1015
[ TRACKED ] , "panic strategy to compile crate with" ) ,
1016
+ incremental: Option <String > = ( None , parse_opt_string, [ UNTRACKED ] ,
1017
+ "enable incremental compilation" ) ,
1016
1018
}
1017
1019
1018
1020
options ! { DebuggingOptions , DebuggingSetter , basic_debugging_options,
@@ -1663,7 +1665,24 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1663
1665
early_error ( error_format, "Value for codegen units must be a positive nonzero integer" ) ;
1664
1666
}
1665
1667
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 ( ) {
1667
1686
early_error ( error_format, "can't perform LTO when compiling incrementally" ) ;
1668
1687
}
1669
1688
@@ -1837,8 +1856,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
1837
1856
1838
1857
let crate_name = matches. opt_str ( "crate-name" ) ;
1839
1858
1840
- let incremental = debugging_opts. incremental . as_ref ( ) . map ( |m| PathBuf :: from ( m) ) ;
1841
-
1842
1859
( Options {
1843
1860
crate_types,
1844
1861
optimize : opt_level,
@@ -2581,6 +2598,9 @@ mod tests {
2581
2598
opts. cg . save_temps = true ;
2582
2599
assert_eq ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
2583
2600
2601
+ opts. cg . incremental = Some ( String :: from ( "abc" ) ) ;
2602
+ assert_eq ! ( reference. dep_tracking_hash( ) , opts. dep_tracking_hash( ) ) ;
2603
+
2584
2604
2585
2605
// Make sure changing a [TRACKED] option changes the hash
2586
2606
opts = reference. clone ( ) ;
0 commit comments