@@ -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
10181020options ! { 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 ( ) ;
0 commit comments