Skip to content

Commit 09d2db4

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 5b800c2 commit 09d2db4

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
@@ -1053,8 +1053,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
10531053
2 = full debug info with variable and type information"),
10541054
opt_level: Option<String> = (None, parse_opt_string, [TRACKED],
10551055
"optimize with possible levels 0-3, s, or z"),
1056-
force_frame_pointers: bool = (false, parse_bool, [TRACKED],
1057-
"force frame pointers to be used"),
1056+
force_frame_pointers: Option<bool> = (None, parse_opt_bool, [TRACKED],
1057+
"force use of the frame pointers"),
10581058
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
10591059
"explicitly enable the cfg(debug_assertions) directive"),
10601060
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2968,7 +2968,7 @@ mod tests {
29682968
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
29692969

29702970
opts = reference.clone();
2971-
opts.cg.force_frame_pointers = true;
2971+
opts.cg.force_frame_pointers = Some(false);
29722972
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
29732973

29742974
opts = reference.clone();

src/librustc/session/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -658,8 +658,11 @@ impl Session {
658658
}
659659

660660
pub fn must_not_eliminate_frame_pointers(&self) -> bool {
661-
self.opts.debuginfo != DebugInfoLevel::NoDebugInfo
662-
|| !self.target.target.options.eliminate_frame_pointer
661+
if let Some(x) = self.opts.cg.force_frame_pointers {
662+
x
663+
} else {
664+
!self.target.target.options.eliminate_frame_pointer
665+
}
663666
}
664667

665668
/// 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)