Add -Z oom={panic,abort} command-line option
This commit is contained in:
parent
1204400ab8
commit
aa36237e16
9 changed files with 113 additions and 10 deletions
|
@ -2735,9 +2735,9 @@ impl PpMode {
|
|||
crate mod dep_tracking {
|
||||
use super::{
|
||||
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, ErrorOutputType,
|
||||
InstrumentCoverage, LdImpl, LinkerPluginLto, LocationDetail, LtoCli, OptLevel, OutputType,
|
||||
OutputTypes, Passes, SourceFileHashAlgorithm, SwitchWithOptPath, SymbolManglingVersion,
|
||||
TrimmedDefPaths,
|
||||
InstrumentCoverage, LdImpl, LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel,
|
||||
OutputType, OutputTypes, Passes, SourceFileHashAlgorithm, SwitchWithOptPath,
|
||||
SymbolManglingVersion, TrimmedDefPaths,
|
||||
};
|
||||
use crate::lint;
|
||||
use crate::options::WasiExecModel;
|
||||
|
@ -2833,6 +2833,7 @@ crate mod dep_tracking {
|
|||
RealFileName,
|
||||
LocationDetail,
|
||||
BranchProtection,
|
||||
OomStrategy,
|
||||
);
|
||||
|
||||
impl<T1, T2> DepTrackingHash for (T1, T2)
|
||||
|
@ -2922,3 +2923,24 @@ crate mod dep_tracking {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Default behavior to use in out-of-memory situations.
|
||||
#[derive(Clone, Copy, PartialEq, Hash, Debug, Encodable, Decodable, HashStable_Generic)]
|
||||
pub enum OomStrategy {
|
||||
/// Generate a panic that can be caught by `catch_unwind`.
|
||||
Panic,
|
||||
|
||||
/// Abort the process immediately.
|
||||
Abort,
|
||||
}
|
||||
|
||||
impl OomStrategy {
|
||||
pub const SYMBOL: &'static str = "__rust_alloc_error_handler_should_panic";
|
||||
|
||||
pub fn should_panic(self) -> u8 {
|
||||
match self {
|
||||
OomStrategy::Panic => 1,
|
||||
OomStrategy::Abort => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -375,6 +375,7 @@ mod desc {
|
|||
pub const parse_passes: &str = "a space-separated list of passes, or `all`";
|
||||
pub const parse_panic_strategy: &str = "either `unwind` or `abort`";
|
||||
pub const parse_opt_panic_strategy: &str = parse_panic_strategy;
|
||||
pub const parse_oom_strategy: &str = "either `panic` or `abort`";
|
||||
pub const parse_relro_level: &str = "one of: `full`, `partial`, or `off`";
|
||||
pub const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `hwaddress`, `leak`, `memory`, `memtag`, or `thread`";
|
||||
pub const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2";
|
||||
|
@ -620,6 +621,15 @@ mod parse {
|
|||
true
|
||||
}
|
||||
|
||||
crate fn parse_oom_strategy(slot: &mut OomStrategy, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("panic") => *slot = OomStrategy::Panic,
|
||||
Some("abort") => *slot = OomStrategy::Abort,
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
crate fn parse_relro_level(slot: &mut Option<RelroLevel>, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some(s) => match s.parse::<RelroLevel>() {
|
||||
|
@ -1328,6 +1338,8 @@ options! {
|
|||
"prevent automatic injection of the profiler_builtins crate"),
|
||||
normalize_docs: bool = (false, parse_bool, [TRACKED],
|
||||
"normalize associated items in rustdoc when generating documentation"),
|
||||
oom: OomStrategy = (OomStrategy::Abort, parse_oom_strategy, [TRACKED],
|
||||
"panic strategy for out-of-memory handling"),
|
||||
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
|
||||
"pass `-install_name @rpath/...` to the macOS linker (default: no)"),
|
||||
panic_abort_tests: bool = (false, parse_bool, [TRACKED],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue