Skip to content

Commit

Permalink
compiler: Support nightly -Cforce-frame-pointers=non-leaf
Browse files Browse the repository at this point in the history
Requires -Zunstable-options as this is a -C flag already.
  • Loading branch information
workingjubilee committed May 14, 2024
1 parent 3aa0ef2 commit cb63601
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
11 changes: 10 additions & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2468,6 +2468,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.
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`";
Expand Down Expand Up @@ -675,9 +676,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
}
Expand Down

0 comments on commit cb63601

Please sign in to comment.