Skip to content

Add rust.debug-assertions-tools option #140438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,12 @@
# Defaults to rust.debug-assertions value
#debug-assertions-std = rust.debug-assertions (boolean)

# Whether or not debug assertions are enabled for the tools built by bootstrap.
# Overrides the `debug-assertions` option, if defined.
#
# Defaults to rust.debug-assertions value
#debug-assertions-tools = rust.debug-assertions (boolean)

# Whether or not to leave debug! and trace! calls in the rust binary.
#
# Defaults to rust.debug-assertions value
Expand Down
14 changes: 9 additions & 5 deletions src/bootstrap/src/core/builder/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,11 +872,15 @@ impl Builder<'_> {
}
cargo.env(
profile_var("DEBUG_ASSERTIONS"),
if mode == Mode::Std {
self.config.std_debug_assertions.to_string()
} else {
self.config.rustc_debug_assertions.to_string()
},
match mode {
Mode::Std => self.config.std_debug_assertions,
Mode::Rustc => self.config.rustc_debug_assertions,
Mode::Codegen => self.config.rustc_debug_assertions,
Mode::ToolBootstrap => self.config.tools_debug_assertions,
Mode::ToolStd => self.config.tools_debug_assertions,
Mode::ToolRustc => self.config.tools_debug_assertions,
}
.to_string(),
);
cargo.env(
profile_var("OVERFLOW_CHECKS"),
Expand Down
8 changes: 8 additions & 0 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ pub struct Config {

pub rustc_debug_assertions: bool,
pub std_debug_assertions: bool,
pub tools_debug_assertions: bool,

pub rust_overflow_checks: bool,
pub rust_overflow_checks_std: bool,
Expand Down Expand Up @@ -1280,6 +1281,7 @@ define_config! {
rustc_debug_assertions: Option<bool> = "debug-assertions",
randomize_layout: Option<bool> = "randomize-layout",
std_debug_assertions: Option<bool> = "debug-assertions-std",
tools_debug_assertions: Option<bool> = "debug-assertions-tools",
overflow_checks: Option<bool> = "overflow-checks",
overflow_checks_std: Option<bool> = "overflow-checks-std",
debug_logging: Option<bool> = "debug-logging",
Expand Down Expand Up @@ -1937,6 +1939,7 @@ impl Config {
let mut debug = None;
let mut rustc_debug_assertions = None;
let mut std_debug_assertions = None;
let mut tools_debug_assertions = None;
let mut overflow_checks = None;
let mut overflow_checks_std = None;
let mut debug_logging = None;
Expand Down Expand Up @@ -2000,6 +2003,7 @@ impl Config {
codegen_units_std,
rustc_debug_assertions: rustc_debug_assertions_toml,
std_debug_assertions: std_debug_assertions_toml,
tools_debug_assertions: tools_debug_assertions_toml,
overflow_checks: overflow_checks_toml,
overflow_checks_std: overflow_checks_std_toml,
debug_logging: debug_logging_toml,
Expand Down Expand Up @@ -2084,6 +2088,7 @@ impl Config {
debug = debug_toml;
rustc_debug_assertions = rustc_debug_assertions_toml;
std_debug_assertions = std_debug_assertions_toml;
tools_debug_assertions = tools_debug_assertions_toml;
overflow_checks = overflow_checks_toml;
overflow_checks_std = overflow_checks_std_toml;
debug_logging = debug_logging_toml;
Expand Down Expand Up @@ -2509,6 +2514,8 @@ impl Config {
let default = debug == Some(true);
config.rustc_debug_assertions = rustc_debug_assertions.unwrap_or(default);
config.std_debug_assertions = std_debug_assertions.unwrap_or(config.rustc_debug_assertions);
config.tools_debug_assertions =
tools_debug_assertions.unwrap_or(config.rustc_debug_assertions);
config.rust_overflow_checks = overflow_checks.unwrap_or(default);
config.rust_overflow_checks_std =
overflow_checks_std.unwrap_or(config.rust_overflow_checks);
Expand Down Expand Up @@ -3568,6 +3575,7 @@ fn check_incompatible_options_for_ci_rustc(
codegen_units_std: _,
rustc_debug_assertions: _,
std_debug_assertions: _,
tools_debug_assertions: _,
overflow_checks: _,
overflow_checks_std: _,
debuginfo_level: _,
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
severity: ChangeSeverity::Info,
summary: "Added new option `include` to create config extensions.",
},
ChangeInfo {
change_id: 140438,
severity: ChangeSeverity::Info,
summary: "Added a new option `rust.debug-assertions-tools` to control debug asssertions for tools.",
},
];
Loading