Skip to content

Commit 24380a6

Browse files
committed
Auto merge of rust-lang#87784 - rusticstuff:bootstrap_config_overflow_checks, r=Mark-Simulacrum
Add config.toml options for enabling overflow checks in rustc and std The names are `overflow-checks` and `overflow-checks-std` and they work similar to `debug-assertions` and `debug-assertions-std`. Once added we can measure how big the performance impact actually is and maybe enable them for CI tests. Enabling them already makes two ui tests fail: ``` failures: [ui] ui/parser/item-free-const-no-body-semantic-fail.rs [ui] ui/parser/item-free-static-no-body-semantic-fail.rs ``` (See rust-lang#84219 and rust-lang#87761.)
2 parents 4c29cc8 + 2f70953 commit 24380a6

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/bootstrap/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
99

1010
- `llvm-libunwind` now accepts `in-tree` (formerly true), `system` or `no` (formerly false) [#77703](https://github.com/rust-lang/rust/pull/77703)
1111
- 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)
12+
- Add options for enabling overflow checks, one for std (`overflow-checks-std`) and one for everything else (`overflow-checks`). Both default to false.
1213

1314
### Non-breaking changes
1415

src/bootstrap/builder.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,14 @@ impl<'a> Builder<'a> {
12051205
self.config.rust_debug_assertions.to_string()
12061206
},
12071207
);
1208+
cargo.env(
1209+
profile_var("OVERFLOW_CHECKS"),
1210+
if mode == Mode::Std {
1211+
self.config.rust_overflow_checks_std.to_string()
1212+
} else {
1213+
self.config.rust_overflow_checks.to_string()
1214+
},
1215+
);
12081216

12091217
// `dsymutil` adds time to builds on Apple platforms for no clear benefit, and also makes
12101218
// it more difficult for debuggers to find debug info. The compiler currently defaults to

src/bootstrap/config.rs

+10
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ pub struct Config {
123123
pub rust_codegen_units_std: Option<u32>,
124124
pub rust_debug_assertions: bool,
125125
pub rust_debug_assertions_std: bool,
126+
pub rust_overflow_checks: bool,
127+
pub rust_overflow_checks_std: bool,
126128
pub rust_debug_logging: bool,
127129
pub rust_debuginfo_level_rustc: u32,
128130
pub rust_debuginfo_level_std: u32,
@@ -473,6 +475,8 @@ struct Rust {
473475
codegen_units_std: Option<u32>,
474476
debug_assertions: Option<bool>,
475477
debug_assertions_std: Option<bool>,
478+
overflow_checks: Option<bool>,
479+
overflow_checks_std: Option<bool>,
476480
debug_logging: Option<bool>,
477481
debuginfo_level: Option<u32>,
478482
debuginfo_level_rustc: Option<u32>,
@@ -710,6 +714,8 @@ impl Config {
710714
let mut debug = None;
711715
let mut debug_assertions = None;
712716
let mut debug_assertions_std = None;
717+
let mut overflow_checks = None;
718+
let mut overflow_checks_std = None;
713719
let mut debug_logging = None;
714720
let mut debuginfo_level = None;
715721
let mut debuginfo_level_rustc = None;
@@ -831,6 +837,8 @@ impl Config {
831837
debug = rust.debug;
832838
debug_assertions = rust.debug_assertions;
833839
debug_assertions_std = rust.debug_assertions_std;
840+
overflow_checks = rust.overflow_checks;
841+
overflow_checks_std = rust.overflow_checks_std;
834842
debug_logging = rust.debug_logging;
835843
debuginfo_level = rust.debuginfo_level;
836844
debuginfo_level_rustc = rust.debuginfo_level_rustc;
@@ -968,6 +976,8 @@ impl Config {
968976
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
969977
config.rust_debug_assertions_std =
970978
debug_assertions_std.unwrap_or(config.rust_debug_assertions);
979+
config.rust_overflow_checks = overflow_checks.unwrap_or(default);
980+
config.rust_overflow_checks_std = overflow_checks_std.unwrap_or(default);
971981

972982
config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);
973983

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def v(*args):
7575
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
7676
o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface")
7777
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions")
78+
o("overflow-checks", "rust.overflow-checks", "build with overflow checks")
7879
o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata")
7980
v("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code")
8081
v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler")

0 commit comments

Comments
 (0)