diff options
| -rw-r--r-- | src/librustc/session/config.rs | 17 | ||||
| -rw-r--r-- | src/librustc_trans/back/write.rs | 13 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 8b55eb4c099..8c4cc20deb7 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1498,6 +1498,23 @@ 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"); } + // It's possible that we have `codegen_units > 1` but only one item in + // `trans.modules`. We could theoretically proceed and do LTO in that + // case, but it would be confusing to have the validity of + // `-Z lto -C codegen-units=2` depend on details of the crate being + // compiled, so we complain regardless. + if cg.lto && cg.codegen_units > 1 { + // This case is impossible to handle because LTO expects to be able + // to combine the entire crate and all its dependencies into a + // single compilation unit, but each codegen unit is in a separate + // LLVM context, so they can't easily be combined. + early_error(error_format, "can't perform LTO when using multiple codegen units"); + } + + if cg.lto && debugging_opts.incremental.is_some() { + early_error(error_format, "can't perform LTO when compiling incrementally"); + } + let mut prints = Vec::<PrintRequest>::new(); if cg.target_cpu.as_ref().map_or(false, |s| s == "help") { prints.push(PrintRequest::TargetCPUs); diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index c1c85394698..967b7d0eb62 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -673,19 +673,6 @@ pub fn run_passes(sess: &Session, linker_info: LinkerInfo, no_integrated_as: bool) -> OngoingCrateTranslation { - // It's possible that we have `codegen_units > 1` but only one item in - // `trans.modules`. We could theoretically proceed and do LTO in that - // case, but it would be confusing to have the validity of - // `-Z lto -C codegen-units=2` depend on details of the crate being - // compiled, so we complain regardless. - if sess.lto() && sess.opts.cg.codegen_units > 1 { - // This case is impossible to handle because LTO expects to be able - // to combine the entire crate and all its dependencies into a - // single compilation unit, but each codegen unit is in a separate - // LLVM context, so they can't easily be combined. - sess.fatal("can't perform LTO when using multiple codegen units"); - } - let output_types_override = if no_integrated_as { OutputTypes::new(&[(OutputType::Assembly, None)]) } else { |
