Only retain external static symbols across LTO
This commit is contained in:
parent
a91ff1c9d1
commit
e6f0f7d52d
6 changed files with 41 additions and 43 deletions
|
|
@ -187,8 +187,7 @@ pub trait CrateStore<'tcx> : Any {
|
|||
fn is_defaulted_trait(&self, did: DefId) -> bool;
|
||||
fn is_impl(&self, did: DefId) -> bool;
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool;
|
||||
fn is_extern_fn(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool;
|
||||
fn is_static(&self, did: DefId) -> bool;
|
||||
fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool;
|
||||
fn is_static_method(&self, did: DefId) -> bool;
|
||||
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool;
|
||||
fn is_typedef(&self, did: DefId) -> bool;
|
||||
|
|
@ -357,8 +356,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
|
|||
fn is_defaulted_trait(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_impl(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_default_impl(&self, impl_did: DefId) -> bool { unimplemented!() }
|
||||
fn is_extern_fn(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_static(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_extern_item(&self, tcx: &ty::ctxt<'tcx>, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_static_method(&self, did: DefId) -> bool { unimplemented!() }
|
||||
fn is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool { false }
|
||||
fn is_typedef(&self, did: DefId) -> bool { unimplemented!() }
|
||||
|
|
|
|||
|
|
@ -229,16 +229,16 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
|
|||
fn propagate_node(&mut self, node: &ast_map::Node,
|
||||
search_item: ast::NodeId) {
|
||||
if !self.any_library {
|
||||
// If we are building an executable, then there's no need to flag
|
||||
// anything as external except for `extern fn` types. These
|
||||
// functions may still participate in some form of native interface,
|
||||
// but all other rust-only interfaces can be private (they will not
|
||||
// participate in linkage after this product is produced)
|
||||
// If we are building an executable, only explicitly extern
|
||||
// types need to be exported.
|
||||
if let ast_map::NodeItem(item) = *node {
|
||||
if let hir::ItemFn(_, _, _, abi, _, _) = item.node {
|
||||
if abi != Abi::Rust {
|
||||
self.reachable_symbols.insert(search_item);
|
||||
}
|
||||
let reachable = if let hir::ItemFn(_, _, _, abi, _, _) = item.node {
|
||||
abi != Abi::Rust
|
||||
} else {
|
||||
false
|
||||
};
|
||||
if reachable || attr::contains_extern_indicator(&item.attrs) {
|
||||
self.reachable_symbols.insert(search_item);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue