compiler: Support nightly -Cforce-frame-pointers=non-leaf

Requires -Zunstable-options as this is a -C flag already.
This commit is contained in:
Jubilee Young 2024-05-04 17:52:47 -07:00
parent f301d087d4
commit 7d160ae61a
2 changed files with 14 additions and 4 deletions

View File

@ -19,7 +19,7 @@
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.

View File

@ -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 @@ pub(crate) fn parse_frame_pointer(slot: &mut FramePointer, v: Option<&str>) -> b
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
}