@@ -33,7 +33,7 @@ macro_rules! check_ci_llvm {
3333 assert!(
3434 $name. is_none( ) ,
3535 "setting {} is incompatible with download-ci-llvm." ,
36- stringify!( $name)
36+ stringify!( $name) . replace ( "_" , "-" )
3737 ) ;
3838 } ;
3939}
@@ -1547,7 +1547,15 @@ impl Config {
15471547 let mut lld_enabled = None ;
15481548
15491549 let mut is_user_configured_rust_channel = false ;
1550+
15501551 if let Some ( rust) = toml. rust {
1552+ config. download_rustc_commit =
1553+ config. download_ci_rustc_commit ( rust. download_rustc . clone ( ) ) ;
1554+
1555+ if config. download_rustc_commit . is_some ( ) {
1556+ check_incompatible_options_for_ci_rustc ( & rust) ;
1557+ }
1558+
15511559 let Rust {
15521560 optimize : optimize_toml,
15531561 debug : debug_toml,
@@ -1595,7 +1603,7 @@ impl Config {
15951603 new_symbol_mangling,
15961604 profile_generate,
15971605 profile_use,
1598- download_rustc,
1606+ download_rustc : _ ,
15991607 lto,
16001608 validate_mir_opts,
16011609 frame_pointers,
@@ -1605,11 +1613,7 @@ impl Config {
16051613 } = rust;
16061614
16071615 is_user_configured_rust_channel = channel. is_some ( ) ;
1608- set ( & mut config. channel , channel) ;
1609-
1610- config. download_rustc_commit = config. download_ci_rustc_commit ( download_rustc) ;
1611-
1612- // FIXME: handle download-rustc incompatible options.
1616+ set ( & mut config. channel , channel. clone ( ) ) ;
16131617
16141618 debug = debug_toml;
16151619 debug_assertions = debug_assertions_toml;
@@ -2591,6 +2595,113 @@ impl Config {
25912595 }
25922596}
25932597
2598+ // Checks the CI rustc incompatible options by destructuring the `Rust` instance
2599+ // and makes sure that no rust options from config.toml are missed.
2600+ fn check_incompatible_options_for_ci_rustc ( rust : & Rust ) {
2601+ macro_rules! err {
2602+ ( $name: expr) => {
2603+ assert!(
2604+ $name. is_none( ) ,
2605+ "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`." ,
2606+ stringify!( $name) . replace( "_" , "-" )
2607+ ) ;
2608+ } ;
2609+ }
2610+
2611+ macro_rules! warn {
2612+ ( $name: expr) => {
2613+ if $name. is_some( ) {
2614+ println!(
2615+ "WARNING: `rust.{}` has no effect with `rust.download-rustc`." ,
2616+ stringify!( $name) . replace( "_" , "-" )
2617+ ) ;
2618+ }
2619+ } ;
2620+ }
2621+
2622+ let Rust {
2623+ // Following options are the CI rustc incompatible ones.
2624+ optimize,
2625+ debug_logging,
2626+ debuginfo_level_rustc,
2627+ llvm_tools,
2628+ llvm_bitcode_linker,
2629+ lto,
2630+ stack_protector,
2631+ strip,
2632+ lld_mode,
2633+ jemalloc,
2634+ rpath,
2635+ channel,
2636+ description,
2637+ incremental,
2638+ default_linker,
2639+
2640+ // Rest of the options can simply be ignored.
2641+ debug : _,
2642+ codegen_units : _,
2643+ codegen_units_std : _,
2644+ debug_assertions : _,
2645+ debug_assertions_std : _,
2646+ overflow_checks : _,
2647+ overflow_checks_std : _,
2648+ debuginfo_level : _,
2649+ debuginfo_level_std : _,
2650+ debuginfo_level_tools : _,
2651+ debuginfo_level_tests : _,
2652+ split_debuginfo : _,
2653+ backtrace : _,
2654+ parallel_compiler : _,
2655+ musl_root : _,
2656+ verbose_tests : _,
2657+ optimize_tests : _,
2658+ codegen_tests : _,
2659+ omit_git_hash : _,
2660+ dist_src : _,
2661+ save_toolstates : _,
2662+ codegen_backends : _,
2663+ lld : _,
2664+ deny_warnings : _,
2665+ backtrace_on_ice : _,
2666+ verify_llvm_ir : _,
2667+ thin_lto_import_instr_limit : _,
2668+ remap_debuginfo : _,
2669+ test_compare_mode : _,
2670+ llvm_libunwind : _,
2671+ control_flow_guard : _,
2672+ ehcont_guard : _,
2673+ new_symbol_mangling : _,
2674+ profile_generate : _,
2675+ profile_use : _,
2676+ download_rustc : _,
2677+ validate_mir_opts : _,
2678+ frame_pointers : _,
2679+ } = rust;
2680+
2681+ // There are two kinds of checks for CI rustc incompatible options:
2682+ // 1. Checking an option that may change the compiler behaviour/output.
2683+ // 2. Checking an option that have no effect on the compiler behaviour/output.
2684+ //
2685+ // If the option belongs to the first category, we call `err` macro for a hard error;
2686+ // otherwise, we just print a warning with `warn` macro.
2687+ err ! ( optimize) ;
2688+ err ! ( debug_logging) ;
2689+ err ! ( debuginfo_level_rustc) ;
2690+ err ! ( default_linker) ;
2691+ err ! ( rpath) ;
2692+ err ! ( strip) ;
2693+ err ! ( stack_protector) ;
2694+ err ! ( lld_mode) ;
2695+ err ! ( llvm_tools) ;
2696+ err ! ( llvm_bitcode_linker) ;
2697+ err ! ( jemalloc) ;
2698+ err ! ( lto) ;
2699+
2700+ warn ! ( channel) ;
2701+ warn ! ( description) ;
2702+ warn ! ( incremental) ;
2703+ }
2704+
25942705fn set < T > ( field : & mut T , val : Option < T > ) {
25952706 if let Some ( v) = val {
25962707 * field = v;
0 commit comments