Skip to content

Commit 935070a

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 rust-lang#11906
1 parent ff2d506 commit 935070a

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
@@ -1064,6 +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"),
10671069
debug_assertions: Option<bool> = (None, parse_opt_bool, [TRACKED],
10681070
"explicitly enable the cfg(debug_assertions) directive"),
10691071
inline_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
@@ -2890,6 +2892,10 @@ mod tests {
28902892
opts.cg.debuginfo = Some(0xba5eba11);
28912893
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
28922894

2895+
opts = reference.clone();
2896+
opts.cg.force_frame_pointers = true;
2897+
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
2898+
28932899
opts = reference.clone();
28942900
opts.cg.debug_assertions = Some(true);
28952901
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::{FxHashMap, FxHashSet};
2626
use util::common::{duration_to_secs_str, ErrorReported};

src/librustc_trans/attributes.rs

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

6767
pub fn set_frame_pointer_elimination(cx: &CodegenCx, llfn: ValueRef) {
68-
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
69-
// parameter.
7068
if cx.sess().must_not_eliminate_frame_pointers() {
7169
llvm::AddFunctionAttrStringValue(
7270
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)