@@ -2505,6 +2505,7 @@ impl Config {
25052505 // Check the config compatibility
25062506 // FIXME: this doesn't cover `--set` flags yet.
25072507 let res = check_incompatible_options_for_ci_rustc (
2508+ self . build ,
25082509 current_config_toml,
25092510 ci_config_toml,
25102511 ) ;
@@ -3086,17 +3087,18 @@ pub(crate) fn check_incompatible_options_for_ci_llvm(
30863087/// Compares the current Rust options against those in the CI rustc builder and detects any incompatible options.
30873088/// It does this by destructuring the `Rust` instance to make sure every `Rust` field is covered and not missing.
30883089fn check_incompatible_options_for_ci_rustc (
3090+ host : TargetSelection ,
30893091 current_config_toml : TomlConfig ,
30903092 ci_config_toml : TomlConfig ,
30913093) -> Result < ( ) , String > {
30923094 macro_rules! err {
3093- ( $current: expr, $expected: expr) => {
3095+ ( $current: expr, $expected: expr, $config_section : expr ) => {
30943096 if let Some ( current) = & $current {
30953097 if Some ( current) != $expected. as_ref( ) {
30963098 return Err ( format!(
3097- "ERROR: Setting `rust. {}` is incompatible with `rust.download-rustc`. \
3099+ "ERROR: Setting `{}` is incompatible with `rust.download-rustc`. \
30983100 Current value: {:?}, Expected value(s): {}{:?}",
3099- stringify!( $expected) . replace( "_" , "-" ) ,
3101+ format! ( "{}.{}" , $config_section , stringify!( $expected) . replace( "_" , "-" ) ) ,
31003102 $current,
31013103 if $expected. is_some( ) { "None/" } else { "" } ,
31023104 $expected,
@@ -3107,13 +3109,13 @@ fn check_incompatible_options_for_ci_rustc(
31073109 }
31083110
31093111 macro_rules! warn {
3110- ( $current: expr, $expected: expr) => {
3112+ ( $current: expr, $expected: expr, $config_section : expr ) => {
31113113 if let Some ( current) = & $current {
31123114 if Some ( current) != $expected. as_ref( ) {
31133115 println!(
3114- "WARNING: `rust. {}` has no effect with `rust.download-rustc`. \
3116+ "WARNING: `{}` has no effect with `rust.download-rustc`. \
31153117 Current value: {:?}, Expected value(s): {}{:?}",
3116- stringify!( $expected) . replace( "_" , "-" ) ,
3118+ format! ( "{}.{}" , $config_section , stringify!( $expected) . replace( "_" , "-" ) ) ,
31173119 $current,
31183120 if $expected. is_some( ) { "None/" } else { "" } ,
31193121 $expected,
@@ -3123,6 +3125,26 @@ fn check_incompatible_options_for_ci_rustc(
31233125 } ;
31243126 }
31253127
3128+ err ! (
3129+ current_config_toml. build. as_ref( ) . and_then( |b| b. profiler) ,
3130+ ci_config_toml. build. as_ref( ) . and_then( |b| b. profiler) ,
3131+ "build"
3132+ ) ;
3133+
3134+ // We always build the in-tree compiler on cross targets, so we only care
3135+ // about the host target here.
3136+ let host_str = host. to_string ( ) ;
3137+ if let Some ( current_cfg) = current_config_toml. target . as_ref ( ) . and_then ( |c| c. get ( & host_str) ) {
3138+ if current_cfg. profiler . is_some ( ) {
3139+ let ci_target_toml = ci_config_toml. target . as_ref ( ) . and_then ( |c| c. get ( & host_str) ) ;
3140+ let ci_cfg = ci_target_toml. ok_or ( format ! (
3141+ "Target specific config for '{host_str}' is not present for CI-rustc"
3142+ ) ) ?;
3143+
3144+ err ! ( current_cfg. profiler, ci_cfg. profiler, "build" ) ;
3145+ }
3146+ }
3147+
31263148 let ( Some ( current_rust_config) , Some ( ci_rust_config) ) =
31273149 ( current_config_toml. rust , ci_config_toml. rust )
31283150 else {
@@ -3196,24 +3218,24 @@ fn check_incompatible_options_for_ci_rustc(
31963218 // If the option belongs to the first category, we call `err` macro for a hard error;
31973219 // otherwise, we just print a warning with `warn` macro.
31983220
3199- err ! ( current_rust_config. optimize, optimize) ;
3200- err ! ( current_rust_config. randomize_layout, randomize_layout) ;
3201- err ! ( current_rust_config. debug_logging, debug_logging) ;
3202- err ! ( current_rust_config. debuginfo_level_rustc, debuginfo_level_rustc) ;
3203- err ! ( current_rust_config. rpath, rpath) ;
3204- err ! ( current_rust_config. strip, strip) ;
3205- err ! ( current_rust_config. lld_mode, lld_mode) ;
3206- err ! ( current_rust_config. llvm_tools, llvm_tools) ;
3207- err ! ( current_rust_config. llvm_bitcode_linker, llvm_bitcode_linker) ;
3208- err ! ( current_rust_config. jemalloc, jemalloc) ;
3209- err ! ( current_rust_config. default_linker, default_linker) ;
3210- err ! ( current_rust_config. stack_protector, stack_protector) ;
3211- err ! ( current_rust_config. lto, lto) ;
3212- err ! ( current_rust_config. std_features, std_features) ;
3213-
3214- warn ! ( current_rust_config. channel, channel) ;
3215- warn ! ( current_rust_config. description, description) ;
3216- warn ! ( current_rust_config. incremental, incremental) ;
3221+ err ! ( current_rust_config. optimize, optimize, "rust" ) ;
3222+ err ! ( current_rust_config. randomize_layout, randomize_layout, "rust" ) ;
3223+ err ! ( current_rust_config. debug_logging, debug_logging, "rust" ) ;
3224+ err ! ( current_rust_config. debuginfo_level_rustc, debuginfo_level_rustc, "rust" ) ;
3225+ err ! ( current_rust_config. rpath, rpath, "rust" ) ;
3226+ err ! ( current_rust_config. strip, strip, "rust" ) ;
3227+ err ! ( current_rust_config. lld_mode, lld_mode, "rust" ) ;
3228+ err ! ( current_rust_config. llvm_tools, llvm_tools, "rust" ) ;
3229+ err ! ( current_rust_config. llvm_bitcode_linker, llvm_bitcode_linker, "rust" ) ;
3230+ err ! ( current_rust_config. jemalloc, jemalloc, "rust" ) ;
3231+ err ! ( current_rust_config. default_linker, default_linker, "rust" ) ;
3232+ err ! ( current_rust_config. stack_protector, stack_protector, "rust" ) ;
3233+ err ! ( current_rust_config. lto, lto, "rust" ) ;
3234+ err ! ( current_rust_config. std_features, std_features, "rust" ) ;
3235+
3236+ warn ! ( current_rust_config. channel, channel, "rust" ) ;
3237+ warn ! ( current_rust_config. description, description, "rust" ) ;
3238+ warn ! ( current_rust_config. incremental, incremental, "rust" ) ;
32173239
32183240 Ok ( ( ) )
32193241}
0 commit comments