Add options for enabling overflow checks in rustc and std.

The options are `overflow-checks` and `overflow-checks-std`
defaulting to false.
This commit is contained in:
Hans Kratz 2021-08-05 05:28:40 +00:00
parent 49ca3d9796
commit 2f7095389d
4 changed files with 20 additions and 0 deletions

View file

@ -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) - `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) - 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 ### Non-breaking changes

View file

@ -1205,6 +1205,14 @@ impl<'a> Builder<'a> {
self.config.rust_debug_assertions.to_string() 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 // `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 // it more difficult for debuggers to find debug info. The compiler currently defaults to

View file

@ -123,6 +123,8 @@ pub struct Config {
pub rust_codegen_units_std: Option<u32>, pub rust_codegen_units_std: Option<u32>,
pub rust_debug_assertions: bool, pub rust_debug_assertions: bool,
pub rust_debug_assertions_std: 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_debug_logging: bool,
pub rust_debuginfo_level_rustc: u32, pub rust_debuginfo_level_rustc: u32,
pub rust_debuginfo_level_std: u32, pub rust_debuginfo_level_std: u32,
@ -473,6 +475,8 @@ struct Rust {
codegen_units_std: Option<u32>, codegen_units_std: Option<u32>,
debug_assertions: Option<bool>, debug_assertions: Option<bool>,
debug_assertions_std: Option<bool>, debug_assertions_std: Option<bool>,
overflow_checks: Option<bool>,
overflow_checks_std: Option<bool>,
debug_logging: Option<bool>, debug_logging: Option<bool>,
debuginfo_level: Option<u32>, debuginfo_level: Option<u32>,
debuginfo_level_rustc: Option<u32>, debuginfo_level_rustc: Option<u32>,
@ -710,6 +714,8 @@ impl Config {
let mut debug = None; let mut debug = None;
let mut debug_assertions = None; let mut debug_assertions = None;
let mut debug_assertions_std = 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 debug_logging = None;
let mut debuginfo_level = None; let mut debuginfo_level = None;
let mut debuginfo_level_rustc = None; let mut debuginfo_level_rustc = None;
@ -831,6 +837,8 @@ impl Config {
debug = rust.debug; debug = rust.debug;
debug_assertions = rust.debug_assertions; debug_assertions = rust.debug_assertions;
debug_assertions_std = rust.debug_assertions_std; debug_assertions_std = rust.debug_assertions_std;
overflow_checks = rust.overflow_checks;
overflow_checks_std = rust.overflow_checks_std;
debug_logging = rust.debug_logging; debug_logging = rust.debug_logging;
debuginfo_level = rust.debuginfo_level; debuginfo_level = rust.debuginfo_level;
debuginfo_level_rustc = rust.debuginfo_level_rustc; 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 = debug_assertions.unwrap_or(default);
config.rust_debug_assertions_std = config.rust_debug_assertions_std =
debug_assertions_std.unwrap_or(config.rust_debug_assertions); 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); config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);

View file

@ -75,6 +75,7 @@ o("optimize-llvm", "llvm.optimize", "build optimized LLVM")
o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("llvm-assertions", "llvm.assertions", "build LLVM with assertions")
o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface") o("llvm-plugins", "llvm.plugins", "build LLVM with plugin interface")
o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") 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") 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", "rust.debuginfo-level", "debuginfo level for Rust code")
v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler") v("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler")