Skip to content

Commit 99336cc

Browse files
committed
handle ci-rustc incompatible options during config parse
This change ensures that `config.toml` does not use CI rustc incompatible options when CI rustc is enabled. This is necessary because some options can change compiler's behavior in certain scenarios. The list may not be complete, but should be a good first step as it's better than nothing! Signed-off-by: onur-ozkan <[email protected]>
1 parent 937b5c4 commit 99336cc

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

src/bootstrap/src/core/config/config.rs

+46-2
Original file line numberDiff line numberDiff line change
@@ -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)]
4260
pub 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

Comments
 (0)