Auto merge of #49904 - michaelwoerister:no-debug-attr, r=alexcrichton
Work around LLVM debuginfo problem in librustc_driver. Works around a problem (https://github.com/rust-lang/rust/issues/48910) with global variable debuginfo generation for `rustc_driver::get_trans::LOAD` by applying `#[no_debug]` to it (which just disables debuginfo generation for that variable). This way we can build the compiler with debuginfo again. Since the problem is also present in beta, this workaround might have to be backported. r? @alexcrichton
This commit is contained in:
commit
786e3058d2
5 changed files with 22 additions and 7 deletions
|
|
@ -2277,6 +2277,7 @@ bitflags! {
|
|||
const NAKED = 0b0001_0000;
|
||||
const NO_MANGLE = 0b0010_0000;
|
||||
const RUSTC_STD_INTERNAL_SYMBOL = 0b0100_0000;
|
||||
const NO_DEBUG = 0b1000_0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#![feature(slice_sort_by_cached_key)]
|
||||
#![feature(set_stdio)]
|
||||
#![feature(rustc_stack_internals)]
|
||||
#![feature(no_debug)]
|
||||
|
||||
extern crate arena;
|
||||
extern crate getopts;
|
||||
|
|
@ -230,6 +231,9 @@ fn load_backend_from_dylib(path: &Path) -> fn() -> Box<TransCrate> {
|
|||
|
||||
pub fn get_trans(sess: &Session) -> Box<TransCrate> {
|
||||
static INIT: Once = ONCE_INIT;
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[no_debug]
|
||||
static mut LOAD: fn() -> Box<TransCrate> = || unreachable!();
|
||||
|
||||
INIT.call_once(|| {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use llvm::{self, ValueRef};
|
|||
use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor,
|
||||
DICompositeType, DILexicalBlock, DIFlags};
|
||||
|
||||
use rustc::hir::TransFnAttrFlags;
|
||||
use rustc::hir::def::CtorKind;
|
||||
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
|
||||
use rustc::ty::fold::TypeVisitor;
|
||||
|
|
@ -41,7 +42,7 @@ use std::ffi::CString;
|
|||
use std::fmt::Write;
|
||||
use std::ptr;
|
||||
use std::path::{Path, PathBuf};
|
||||
use syntax::{ast, attr};
|
||||
use syntax::ast;
|
||||
use syntax::symbol::{Interner, InternedString, Symbol};
|
||||
use syntax_pos::{self, Span, FileName};
|
||||
|
||||
|
|
@ -1644,11 +1645,17 @@ pub fn create_global_var_metadata(cx: &CodegenCx,
|
|||
}
|
||||
|
||||
let tcx = cx.tcx;
|
||||
let no_mangle = attr::contains_name(&tcx.get_attrs(def_id), "no_mangle");
|
||||
let attrs = tcx.trans_fn_attrs(def_id);
|
||||
|
||||
if attrs.flags.contains(TransFnAttrFlags::NO_DEBUG) {
|
||||
return;
|
||||
}
|
||||
|
||||
let no_mangle = attrs.flags.contains(TransFnAttrFlags::NO_MANGLE);
|
||||
// We may want to remove the namespace scope if we're in an extern block, see:
|
||||
// https://github.com/rust-lang/rust/pull/46457#issuecomment-351750952
|
||||
let var_scope = get_namespace_for_item(cx, def_id);
|
||||
let span = cx.tcx.def_span(def_id);
|
||||
let span = tcx.def_span(def_id);
|
||||
|
||||
let (file_metadata, line_number) = if span != syntax_pos::DUMMY_SP {
|
||||
let loc = span_start(cx, span);
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use self::source_loc::InternalDebugLocation::{self, UnknownLocation};
|
|||
use llvm;
|
||||
use llvm::{ModuleRef, ContextRef, ValueRef};
|
||||
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray, DIFlags};
|
||||
use rustc::hir::TransFnAttrFlags;
|
||||
use rustc::hir::def_id::{DefId, CrateNum};
|
||||
use rustc::ty::subst::Substs;
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ use abi::Abi;
|
|||
use common::CodegenCx;
|
||||
use builder::Builder;
|
||||
use monomorphize::Instance;
|
||||
use rustc::ty::{self, ParamEnv, Ty};
|
||||
use rustc::ty::{self, ParamEnv, Ty, InstanceDef};
|
||||
use rustc::mir;
|
||||
use rustc::session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
|
||||
use rustc::util::nodemap::{DefIdMap, FxHashMap, FxHashSet};
|
||||
|
|
@ -210,13 +211,12 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
return FunctionDebugContext::DebugInfoDisabled;
|
||||
}
|
||||
|
||||
for attr in instance.def.attrs(cx.tcx).iter() {
|
||||
if attr.check_name("no_debug") {
|
||||
if let InstanceDef::Item(def_id) = instance.def {
|
||||
if cx.tcx.trans_fn_attrs(def_id).flags.contains(TransFnAttrFlags::NO_DEBUG) {
|
||||
return FunctionDebugContext::FunctionWithoutDebugInfo;
|
||||
}
|
||||
}
|
||||
|
||||
let containing_scope = get_containing_scope(cx, instance);
|
||||
let span = mir.span;
|
||||
|
||||
// This can be the case for functions inlined from another crate
|
||||
|
|
@ -226,6 +226,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
}
|
||||
|
||||
let def_id = instance.def_id();
|
||||
let containing_scope = get_containing_scope(cx, instance);
|
||||
let loc = span_start(cx, span);
|
||||
let file_metadata = file_metadata(cx, &loc.file.name, def_id.krate);
|
||||
|
||||
|
|
|
|||
|
|
@ -1825,6 +1825,8 @@ fn trans_fn_attrs<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: DefId) -> TransFnAt
|
|||
trans_fn_attrs.flags |= TransFnAttrFlags::NO_MANGLE;
|
||||
} else if attr.check_name("rustc_std_internal_symbol") {
|
||||
trans_fn_attrs.flags |= TransFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
|
||||
} else if attr.check_name("no_debug") {
|
||||
trans_fn_attrs.flags |= TransFnAttrFlags::NO_DEBUG;
|
||||
} else if attr.check_name("inline") {
|
||||
trans_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| {
|
||||
if attr.path != "inline" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue