Skip to content

Commit 5b800c2

Browse files
dotdashnagisa
authored andcommitted
Don't force-enable frame pointers when generating debug info
We apparently used to generate bad/incomplete debug info causing debuggers not to find symbols of stack allocated variables. This was somehow worked around by having frame pointers. With the current codegen, this seems no longer necessary, so we can remove the code that force-enables frame pointers whenever debug info is requested. Since certain situations, like profiling code profit from having frame pointers, we add a -Cforce-frame-pointers flag to always enable frame pointers. Fixes #11906
1 parent 2a8ad90 commit 5b800c2

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

src/librustc/session/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1053,6 +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"),
10561058
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
10571059
"explicitly enable the cfg(debug_assertions) directive"),
10581060
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2965,6 +2967,10 @@ mod tests {
29652967
opts.cg.debuginfo = Some(0xba5eba11);
29662968
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
29672969

2970+
opts = reference.clone();
2971+
opts.cg.force_frame_pointers = true;
2972+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
2973+
29682974
opts = reference.clone();
29692975
opts.cg.debug_assertions = Some(true);
29702976
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

src/librustc/session/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use lint::builtin::BuiltinLintDiagnostics;
2020
use middle::allocator::AllocatorKind;
2121
use middle::dependency_format;
2222
use session::search_paths::PathKind;
23-
use session::config::{DebugInfoLevel, OutputType};
23+
use session::config::{OutputType};
2424
use ty::tls;
2525
use util::nodemap::{FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};

src/librustc_trans/attributes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ pub fn naked(val: ValueRef, is_naked: bool) {
6969
}
7070

7171
pub fn set_frame_pointer_elimination(cx: &CodegenCx, llfn: ValueRef) {
72-
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
73-
// parameter.
7472
if cx.sess().must_not_eliminate_frame_pointers() {
7573
llvm::AddFunctionAttrStringValue(
7674
llfn, llvm::AttributePlace::Function,
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
// compile-flags: -C no-prepopulate-passes -C force-frame-pointers
12+
13+
#![crate_type="lib"]
14+
15+
// CHECK: attributes #{{.*}} "no-frame-pointer-elim"="true"
16+
pub fn foo() {}

0 commit comments

Comments
 (0)