diff options
| author | bors <bors@rust-lang.org> | 2018-04-17 19:26:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-04-17 19:26:25 +0000 |
| commit | 786e3058d20dacbc807e6e30705f58e17432738e (patch) | |
| tree | 9b39c2d333161dc48713bcc27f6af5ae878eede7 /src | |
| parent | 9379bcdd0b4ef06303e8c4e3e7c3fd79882372cc (diff) | |
| parent | 281492898be7fd6b9705a818d2c880e9d7fd2da0 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/hir/mod.rs | 1 | ||||
| -rw-r--r-- | src/librustc_driver/lib.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/debuginfo/metadata.rs | 13 | ||||
| -rw-r--r-- | src/librustc_trans/debuginfo/mod.rs | 9 | ||||
| -rw-r--r-- | src/librustc_typeck/collect.rs | 2 |
5 files changed, 22 insertions, 7 deletions
diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index e6080fad91d..f471ffb072d 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -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; } } diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index cb91ff6a43e..fb333ec38fb 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -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(|| { diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index f3d95cf794b..eb550d7a605 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -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); diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 28311018ee7..706dc3dca8a 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -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); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d9e5ac7f7c5..6bd38244e8c 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -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" { |
