From 7fe41279c5b6cca8c16f94f12ef4bf8811943599 Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Fri, 17 Apr 2020 19:53:31 +0100 Subject: [PATCH] Make -Zprofile set codegen-units to 1 --- src/librustc_session/config.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs index aaf30c583e2..ba2a4d1d56f 100644 --- a/src/librustc_session/config.rs +++ b/src/librustc_session/config.rs @@ -1655,7 +1655,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let output_types = parse_output_types(&debugging_opts, matches, error_format); let mut cg = build_codegen_options(matches, error_format); - let (disable_thinlto, codegen_units) = should_override_cgus_and_disable_thinlto( + let (disable_thinlto, mut codegen_units) = should_override_cgus_and_disable_thinlto( &output_types, matches, error_format, @@ -1672,6 +1672,16 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { "can't instrument with gcov profiling when compiling incrementally", ); } + if debugging_opts.profile { + match codegen_units { + Some(1) => {} + None => codegen_units = Some(1), + Some(_) => early_error( + error_format, + "can't instrument with gcov profiling with multiple codegen units", + ), + } + } if cg.profile_generate.enabled() && cg.profile_use.is_some() { early_error(