diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 34eaa74cc38..f4e24cd4606 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -19,7 +19,7 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION}; use rustc_span::source_map::FilePathMapping; use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm}; -use rustc_target::spec::{LinkSelfContainedComponents, LinkerFeatures}; +use rustc_target::spec::{FramePointer, LinkSelfContainedComponents, LinkerFeatures}; use rustc_target::spec::{SplitDebuginfo, Target, TargetTriple}; use std::collections::btree_map::{ Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, @@ -2524,6 +2524,15 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M } } + if !nightly_options::is_unstable_enabled(matches) + && cg.force_frame_pointers == FramePointer::NonLeaf + { + early_dcx.early_fatal( + "`-Cforce-frame-pointers=non-leaf` also requires `-Zunstable-options` \ + and a nightly compiler", + ) + } + // For testing purposes, until we have more feedback about these options: ensure `-Z // unstable-options` is required when using the unstable `-C link-self-contained` and `-C // linker-flavor` options. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index ce64e9113f4..75f0e9a616c 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -373,7 +373,8 @@ mod desc { pub const parse_opt_comma_list: &str = parse_comma_list; pub const parse_number: &str = "a number"; pub const parse_opt_number: &str = parse_number; - pub const parse_frame_pointer: &str = parse_bool; + pub const parse_frame_pointer: &str = + "one of `true`/`yes`/`on`, `false`/`no`/`off`, or (with -Zunstable-options) `non-leaf`"; pub const parse_threads: &str = parse_number; pub const parse_time_passes_format: &str = "`text` (default) or `json`"; pub const parse_passes: &str = "a space-separated list of passes, or `all`"; @@ -677,9 +678,9 @@ mod parse { let mut is_parsed = parse_bool(&mut boolish, v); if boolish & is_parsed { *slot = FramePointer::Always; - } else if false { - /* TODO: add NonLeaf as an unstable opt */ + } else if v == Some("non-leaf") { is_parsed = true; + *slot = FramePointer::NonLeaf; }; is_parsed }