Skip to content

Commit 7188f41

Browse files
committed
Rework force-frame-pointer
This reworks the force-frame-pointer PR to explicitly only consider the value of the flag if it is provided, and use a target default otherwise. Something that was tried but not kept was renaming the flag to `frame-pointer`, because for flag `frame-pointer=no`, there is no guarante, that LLVM will elide *all* the frame pointers; oposite of what the literal reading of the flag would suggest.
1 parent 935070a commit 7188f41

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/librustc/session/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10641064
2 = full debug info with variable and type information"),
10651065
opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
10661066
"optimize with possible levels 0-3, s, or z"),
1067-
force_frame_pointers: bool = (false, parse_bool, [TRACKED],
1068-
"force frame pointers to be used"),
1067+
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
1068+
"force use of the frame pointers"),
10691069
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
10701070
"explicitly enable the cfg(debug_assertions) directive"),
10711071
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2893,7 +2893,7 @@ mod tests {
28932893
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
28942894

28952895
opts = reference.clone();
2896-
opts.cg.force_frame_pointers = true;
2896+
opts.cg.force_frame_pointers = Some(false);
28972897
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
28982898

28992899
opts = reference.clone();

src/librustc/session/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,11 @@ impl Session {
676676
}
677677

678678
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
679-
self.opts.debuginfo != DebugInfoLevel::NoDebugInfo
680-
|| !self.target.target.options.eliminate_frame_pointer
679+
if let Some(x) = self.opts.cg.force_frame_pointers {
680+
x
681+
} else {
682+
!self.target.target.options.eliminate_frame_pointer
683+
}
681684
}
682685

683686
/// Returns the symbol name for the registrar function,

src/test/codegen/force-frame-pointers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010
//
11-
// compile-flags: -C no-prepopulate-passes -C force-frame-pointers
11+
// compile-flags: -C no-prepopulate-passes -C force-frame-pointers=y
1212

1313
#![crate_type="lib"]
1414

0 commit comments

Comments
 (0)