@@ -38,6 +38,24 @@ macro_rules! check_ci_llvm {
3838 } ;
3939}
4040
41+ macro_rules! err_incompatible_ci_rustc_option {
42+ ( $name: expr, $option_name: literal) => {
43+ assert!(
44+ $name. is_none( ) ,
45+ "ERROR: Setting `rust.{}` is incompatible with `rust.download-rustc`." ,
46+ $option_name
47+ ) ;
48+ } ;
49+ }
50+
51+ macro_rules! warn_incompatible_ci_rustc_option {
52+ ( $name: expr, $option_name: literal) => {
53+ if $name. is_some( ) {
54+ println!( "WARNING: `rust.{}` has no effect with `rust.download-rustc`." , $option_name) ;
55+ }
56+ } ;
57+ }
58+
4159#[ derive( Clone , Default ) ]
4260pub enum DryRun {
4361 /// This isn't a dry run.
@@ -1605,11 +1623,37 @@ impl Config {
16051623 } = rust;
16061624
16071625 is_user_configured_rust_channel = channel. is_some ( ) ;
1608- set ( & mut config. channel , channel) ;
1626+ set ( & mut config. channel , channel. clone ( ) ) ;
16091627
16101628 config. download_rustc_commit = config. download_ci_rustc_commit ( download_rustc) ;
16111629
1612- // FIXME: handle download-rustc incompatible options.
1630+ // There are two kinds of checks for CI rustc incompatible options:
1631+ // 1. Checking an option that may change the compiler behaviour/output.
1632+ // 2. Checking an option that have no effect on the compiler behaviour/output.
1633+ //
1634+ // If the option belongs to the first category, we call `err_incompatible_ci_rustc_option` macro
1635+ // for a hard error; otherwise, we just print a warning with `warn_incompatible_ci_rustc_option` macro.
1636+ if config. download_rustc_commit . is_some ( ) {
1637+ err_incompatible_ci_rustc_option ! ( optimize_toml, "optimize" ) ;
1638+ err_incompatible_ci_rustc_option ! ( debug_logging, "debug-logging" ) ;
1639+ err_incompatible_ci_rustc_option ! (
1640+ debuginfo_level_rustc_toml,
1641+ "debuginfo-level-rustc"
1642+ ) ;
1643+ err_incompatible_ci_rustc_option ! ( default_linker, "default-linker" ) ;
1644+ err_incompatible_ci_rustc_option ! ( rpath, "rpath" ) ;
1645+ err_incompatible_ci_rustc_option ! ( strip, "strip" ) ;
1646+ err_incompatible_ci_rustc_option ! ( stack_protector, "stack-protector" ) ;
1647+ err_incompatible_ci_rustc_option ! ( lld_mode, "use-lld" ) ;
1648+ err_incompatible_ci_rustc_option ! ( llvm_tools, "llvm-tools" ) ;
1649+ err_incompatible_ci_rustc_option ! ( llvm_bitcode_linker, "llvm-bitcode-linker" ) ;
1650+ err_incompatible_ci_rustc_option ! ( jemalloc, "jemalloc" ) ;
1651+ err_incompatible_ci_rustc_option ! ( lto, "lto" ) ;
1652+
1653+ warn_incompatible_ci_rustc_option ! ( channel, "channel" ) ;
1654+ warn_incompatible_ci_rustc_option ! ( description, "description" ) ;
1655+ warn_incompatible_ci_rustc_option ! ( incremental, "incremental" ) ;
1656+ }
16131657
16141658 debug = debug_toml;
16151659 debug_assertions = debug_assertions_toml;
0 commit comments