Preserve public static items across LTO
This commit is contained in:
parent
02d9f29455
commit
892b50ba74
5 changed files with 20 additions and 2 deletions
|
@ -344,6 +344,11 @@ pub fn is_const_fn(cstore: &cstore::CStore, did: DefId) -> bool {
|
||||||
decoder::is_const_fn(&*cdata, did.index)
|
decoder::is_const_fn(&*cdata, did.index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_static(cstore: &cstore::CStore, did: DefId) -> bool {
|
||||||
|
let cdata = cstore.get_crate_data(did.krate);
|
||||||
|
decoder::is_static(&*cdata, did.index)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_impl(cstore: &cstore::CStore, did: DefId) -> bool {
|
pub fn is_impl(cstore: &cstore::CStore, did: DefId) -> bool {
|
||||||
let cdata = cstore.get_crate_data(did.krate);
|
let cdata = cstore.get_crate_data(did.krate);
|
||||||
decoder::is_impl(&*cdata, did.index)
|
decoder::is_impl(&*cdata, did.index)
|
||||||
|
|
|
@ -1425,6 +1425,14 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_static(cdata: Cmd, id: DefIndex) -> bool {
|
||||||
|
let item_doc = cdata.lookup_item(id);
|
||||||
|
match item_family(item_doc) {
|
||||||
|
ImmStatic | MutStatic => true,
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_impl(cdata: Cmd, id: DefIndex) -> bool {
|
pub fn is_impl(cdata: Cmd, id: DefIndex) -> bool {
|
||||||
let item_doc = cdata.lookup_item(id);
|
let item_doc = cdata.lookup_item(id);
|
||||||
match item_family(item_doc) {
|
match item_family(item_doc) {
|
||||||
|
|
|
@ -2875,7 +2875,8 @@ pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||||
sess.cstore.iter_crate_data(|cnum, _| {
|
sess.cstore.iter_crate_data(|cnum, _| {
|
||||||
let syms = csearch::get_reachable_ids(&sess.cstore, cnum);
|
let syms = csearch::get_reachable_ids(&sess.cstore, cnum);
|
||||||
reachable_symbols.extend(syms.into_iter().filter(|did| {
|
reachable_symbols.extend(syms.into_iter().filter(|did| {
|
||||||
csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx())
|
csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx()) ||
|
||||||
|
csearch::is_static(&sess.cstore, *did)
|
||||||
}).map(|did| {
|
}).map(|did| {
|
||||||
csearch::get_symbol(&sess.cstore, did)
|
csearch::get_symbol(&sess.cstore, did)
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
extern void foo();
|
extern void foo();
|
||||||
|
extern char FOO_STATIC;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
foo();
|
foo();
|
||||||
return 0;
|
return (int)FOO_STATIC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,3 +10,6 @@
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn foo() {}
|
pub extern fn foo() {}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub static FOO_STATIC: u8 = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue