diff --git a/src/bootstrap/CHANGELOG.md b/src/bootstrap/CHANGELOG.md index 8437a10426b71..2f99e36aef219 100644 --- a/src/bootstrap/CHANGELOG.md +++ b/src/bootstrap/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `llvm-libunwind` now accepts `in-tree` (formerly true), `system` or `no` (formerly false) [#77703](https://github.com/rust-lang/rust/pull/77703) - The options `infodir`, `localstatedir`, and `gpg-password-file` are no longer allowed in config.toml. Previously, they were ignored without warning. Note that `infodir` and `localstatedir` are still accepted by `./configure`, with a warning. [#82451](https://github.com/rust-lang/rust/pull/82451) +- Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false. ### Non-breaking changes diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f2d841cb335ab..34708fb0816df 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -1205,6 +1205,14 @@ impl<'a> Builder<'a> { self.config.rust_debug_assertions.to_string() }, ); + cargo.env( + profile_var("OVERFLOW_CHECKS"), + if mode == Mode::Std { + self.config.rust_overflow_checks_std.to_string() + } else { + self.config.rust_overflow_checks.to_string() + }, + ); // `dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes // it more difficult for debuggers to find debug info. The compiler currently defaults to diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index fdddc1dbbaf77..dd536cb7b02bf 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -123,6 +123,8 @@ pub struct Config { pub rust_codegen_units_std: Option, pub rust_debug_assertions: bool, pub rust_debug_assertions_std: bool, + pub rust_overflow_checks: bool, + pub rust_overflow_checks_std: bool, pub rust_debug_logging: bool, pub rust_debuginfo_level_rustc: u32, pub rust_debuginfo_level_std: u32, @@ -473,6 +475,8 @@ struct Rust { codegen_units_std: Option, debug_assertions: Option, debug_assertions_std: Option, + overflow_checks: Option, + overflow_checks_std: Option, debug_logging: Option, debuginfo_level: Option, debuginfo_level_rustc: Option, @@ -710,6 +714,8 @@ impl Config { let mut debug = None; let mut debug_assertions = None; let mut debug_assertions_std = None; + let mut overflow_checks = None; + let mut overflow_checks_std = None; let mut debug_logging = None; let mut debuginfo_level = None; let mut debuginfo_level_rustc = None; @@ -831,6 +837,8 @@ impl Config { debug = rust.debug; debug_assertions = rust.debug_assertions; debug_assertions_std = rust.debug_assertions_std; + overflow_checks = rust.overflow_checks; + overflow_checks_std = rust.overflow_checks_std; debug_logging = rust.debug_logging; debuginfo_level = rust.debuginfo_level; debuginfo_level_rustc = rust.debuginfo_level_rustc; @@ -968,6 +976,8 @@ impl Config { config.rust_debug_assertions = debug_assertions.unwrap_or(default); config.rust_debug_assertions_std = debug_assertions_std.unwrap_or(config.rust_debug_assertions); + config.rust_overflow_checks = overflow_checks.unwrap_or(default); + config.rust_overflow_checks_std = overflow_checks_std.unwrap_or(default); config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index a1941efb5621b..fd148d14478d8 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -75,6 +75,7 @@ def v(*args): o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") +o("overflow-checks", "rust.overflow-checks", "build with overflow checks") o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata") v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code") v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler")