Skip to content

Commit c59d89f

Browse files
committed
Only retain no_mangle static symbols across LTO
1 parent f1f5c04 commit c59d89f

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,9 @@ pub fn is_const_fn(cstore: &cstore::CStore, did: DefId) -> bool {
344344
decoder::is_const_fn(&*cdata, did.index)
345345
}
346346

347-
pub fn is_static(cstore: &cstore::CStore, did: DefId) -> bool {
347+
pub fn is_extern_static(cstore: &cstore::CStore, did: DefId) -> bool {
348348
let cdata = cstore.get_crate_data(did.krate);
349-
decoder::is_static(&*cdata, did.index)
349+
decoder::is_extern_static(&*cdata, did.index)
350350
}
351351

352352
pub fn is_impl(cstore: &cstore::CStore, did: DefId) -> bool {

src/librustc/metadata/decoder.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,10 +1425,13 @@ pub fn is_const_fn(cdata: Cmd, id: DefIndex) -> bool {
14251425
}
14261426
}
14271427

1428-
pub fn is_static(cdata: Cmd, id: DefIndex) -> bool {
1428+
pub fn is_extern_static(cdata: Cmd, id: DefIndex) -> bool {
14291429
let item_doc = cdata.lookup_item(id);
14301430
match item_family(item_doc) {
1431-
ImmStatic | MutStatic => true,
1431+
ImmStatic | MutStatic => {
1432+
let attrs = get_attributes(item_doc);
1433+
attr::contains_name(&attrs, "no_mangle")
1434+
},
14321435
_ => false,
14331436
}
14341437
}

src/librustc_trans/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,7 @@ pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
28762876
let syms = csearch::get_reachable_ids(&sess.cstore, cnum);
28772877
reachable_symbols.extend(syms.into_iter().filter(|did| {
28782878
csearch::is_extern_fn(&sess.cstore, *did, shared_ccx.tcx()) ||
2879-
csearch::is_static(&sess.cstore, *did)
2879+
csearch::is_extern_static(&sess.cstore, *did)
28802880
}).map(|did| {
28812881
csearch::get_symbol(&sess.cstore, did)
28822882
}));

0 commit comments

Comments
 (0)