mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
debuginfo: Don't create debuginfo for statics inlined from other crates.
Fixes issue #13213, that is linker errors when the inlined static has been optimized out of the exporting crate.
This commit is contained in:
parent
c26d25466d
commit
5099b8c863
@ -293,6 +293,13 @@ pub fn create_global_var_metadata(cx: &CrateContext,
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't create debuginfo for globals inlined from other crates. The other crate should already
|
||||
// contain debuginfo for it. More importantly, the global might not even exist in un-inlined
|
||||
// form anywhere which would lead to a linker errors.
|
||||
if cx.external_srcs.borrow().contains_key(&node_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
let var_item = cx.tcx.map.get(node_id);
|
||||
|
||||
let (ident, span) = match var_item {
|
||||
|
27
src/test/auxiliary/issue13213aux.rs
Normal file
27
src/test/auxiliary/issue13213aux.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![crate_type = "lib"]
|
||||
// compile-flags:-g
|
||||
|
||||
pub use private::P;
|
||||
|
||||
pub struct S {
|
||||
p: P,
|
||||
}
|
||||
|
||||
mod private {
|
||||
pub struct P {
|
||||
p: i32,
|
||||
}
|
||||
pub static THREE: P = P { p: 3 };
|
||||
}
|
||||
|
||||
pub static A: S = S { p: private::THREE };
|
26
src/test/debug-info/issue13213.rs
Normal file
26
src/test/debug-info/issue13213.rs
Normal file
@ -0,0 +1,26 @@
|
||||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-android: FIXME(#10381)
|
||||
|
||||
// aux-build:issue13213aux.rs
|
||||
extern crate issue13213aux;
|
||||
|
||||
// compile-flags:-g
|
||||
|
||||
// This tests make sure that we get no linker error when using a completely inlined static. Some
|
||||
// statics that are marked with AvailableExternallyLinkage in the importing crate, may actually not
|
||||
// be available because they have been optimized out from the exporting crate.
|
||||
fn main() {
|
||||
let b: issue13213aux::S = issue13213aux::A;
|
||||
zzz();
|
||||
}
|
||||
|
||||
fn zzz() {()}
|
Loading…
Reference in New Issue
Block a user