Skip to content

Commit 4fe94ba

Browse files
committed
add rust.debug-assertions-tools option
1 parent 0134651 commit 4fe94ba

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

bootstrap.example.toml

+6
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@
570570
# Defaults to rust.debug-assertions value
571571
#debug-assertions-std = rust.debug-assertions (boolean)
572572

573+
# Whether or not debug assertions are enabled for the tools built by bootstrap.
574+
# Overrides the `debug-assertions` option, if defined.
575+
#
576+
# Defaults to rust.debug-assertions value
577+
#debug-assertions-tools = rust.debug-assertions (boolean)
578+
573579
# Whether or not to leave debug! and trace! calls in the rust binary.
574580
#
575581
# Defaults to rust.debug-assertions value

src/bootstrap/src/core/builder/cargo.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -872,11 +872,15 @@ impl Builder<'_> {
872872
}
873873
cargo.env(
874874
profile_var("DEBUG_ASSERTIONS"),
875-
if mode == Mode::Std {
876-
self.config.std_debug_assertions.to_string()
877-
} else {
878-
self.config.rustc_debug_assertions.to_string()
879-
},
875+
match mode {
876+
Mode::Std => self.config.std_debug_assertions,
877+
Mode::Rustc => self.config.rustc_debug_assertions,
878+
Mode::Codegen => self.config.rustc_debug_assertions,
879+
Mode::ToolBootstrap => self.config.tools_debug_assertions,
880+
Mode::ToolStd => self.config.tools_debug_assertions,
881+
Mode::ToolRustc => self.config.tools_debug_assertions,
882+
}
883+
.to_string(),
880884
);
881885
cargo.env(
882886
profile_var("OVERFLOW_CHECKS"),

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

+8
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ pub struct Config {
306306

307307
pub rustc_debug_assertions: bool,
308308
pub std_debug_assertions: bool,
309+
pub tools_debug_assertions: bool,
309310

310311
pub rust_overflow_checks: bool,
311312
pub rust_overflow_checks_std: bool,
@@ -1280,6 +1281,7 @@ define_config! {
12801281
rustc_debug_assertions: Option<bool> = "debug-assertions",
12811282
randomize_layout: Option<bool> = "randomize-layout",
12821283
std_debug_assertions: Option<bool> = "debug-assertions-std",
1284+
tools_debug_assertions: Option<bool> = "debug-assertions-tools",
12831285
overflow_checks: Option<bool> = "overflow-checks",
12841286
overflow_checks_std: Option<bool> = "overflow-checks-std",
12851287
debug_logging: Option<bool> = "debug-logging",
@@ -1937,6 +1939,7 @@ impl Config {
19371939
let mut debug = None;
19381940
let mut rustc_debug_assertions = None;
19391941
let mut std_debug_assertions = None;
1942+
let mut tools_debug_assertions = None;
19401943
let mut overflow_checks = None;
19411944
let mut overflow_checks_std = None;
19421945
let mut debug_logging = None;
@@ -2000,6 +2003,7 @@ impl Config {
20002003
codegen_units_std,
20012004
rustc_debug_assertions: rustc_debug_assertions_toml,
20022005
std_debug_assertions: std_debug_assertions_toml,
2006+
tools_debug_assertions: tools_debug_assertions_toml,
20032007
overflow_checks: overflow_checks_toml,
20042008
overflow_checks_std: overflow_checks_std_toml,
20052009
debug_logging: debug_logging_toml,
@@ -2084,6 +2088,7 @@ impl Config {
20842088
debug = debug_toml;
20852089
rustc_debug_assertions = rustc_debug_assertions_toml;
20862090
std_debug_assertions = std_debug_assertions_toml;
2091+
tools_debug_assertions = tools_debug_assertions_toml;
20872092
overflow_checks = overflow_checks_toml;
20882093
overflow_checks_std = overflow_checks_std_toml;
20892094
debug_logging = debug_logging_toml;
@@ -2509,6 +2514,8 @@ impl Config {
25092514
let default = debug == Some(true);
25102515
config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default);
25112516
config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions);
2517+
config.tools_debug_assertions =
2518+
tools_debug_assertions.unwrap_or(config.rustc_debug_assertions);
25122519
config.rust_overflow_checks = overflow_checks.unwrap_or(default);
25132520
config.rust_overflow_checks_std =
25142521
overflow_checks_std.unwrap_or(config.rust_overflow_checks);
@@ -3568,6 +3575,7 @@ fn check_incompatible_options_for_ci_rustc(
35683575
codegen_units_std: _,
35693576
rustc_debug_assertions: _,
35703577
std_debug_assertions: _,
3578+
tools_debug_assertions: _,
35713579
overflow_checks: _,
35723580
overflow_checks_std: _,
35733581
debuginfo_level: _,

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
401401
severity: ChangeSeverity::Info,
402402
summary: "Added new option `include` to create config extensions.",
403403
},
404+
ChangeInfo {
405+
change_id: 140438,
406+
severity: ChangeSeverity::Info,
407+
summary: "Added a new option `rust.debug-assertions-tools` to control debug asssertions for tools.",
408+
},
404409
];

0 commit comments

Comments
 (0)