Fix export level of plugin and procmacro registrars.

This commit is contained in:
Michael Woerister 2018-02-28 17:40:25 +01:00
parent 8bc005c8bb
commit 9f6d554638
2 changed files with 14 additions and 13 deletions

View file

@ -256,10 +256,9 @@ provide! { <'tcx> tcx, def_id, other, cdata,
let cnum = cdata.cnum;
assert!(cnum != LOCAL_CRATE);
// If this crate is a plugin and/or a custom derive crate, then
// we're not even going to link those in so we skip those crates.
if cdata.root.plugin_registrar_fn.is_some() ||
cdata.root.macro_derive_registrar.is_some() {
// If this crate is a custom derive crate, then we're not even going to
// link those in so we skip those crates.
if cdata.root.macro_derive_registrar.is_some() {
return Arc::new(Vec::new())
}

View file

@ -119,7 +119,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let special_runtime_crate = tcx.is_panic_runtime(LOCAL_CRATE) ||
tcx.is_compiler_builtins(LOCAL_CRATE);
let mut reachable_non_generics: DefIdSet = tcx.reachable_set(LOCAL_CRATE).0
let reachable_non_generics: DefIdSet = tcx.reachable_set(LOCAL_CRATE).0
.iter()
.filter_map(|&node_id| {
// We want to ignore some FFI functions that are not exposed from
@ -174,14 +174,6 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
})
.collect();
if let Some(id) = tcx.sess.derive_registrar_fn.get() {
reachable_non_generics.insert(tcx.hir.local_def_id(id));
}
if let Some(id) = tcx.sess.plugin_registrar_fn.get() {
reachable_non_generics.insert(tcx.hir.local_def_id(id));
}
let mut symbols: Vec<_> = reachable_non_generics
.iter()
.map(|&def_id| {
@ -211,6 +203,16 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
})
.collect();
if let Some(id) = tcx.sess.derive_registrar_fn.get() {
let def_id = tcx.hir.local_def_id(id);
symbols.push((ExportedSymbol::NonGeneric(def_id), SymbolExportLevel::C));
}
if let Some(id) = tcx.sess.plugin_registrar_fn.get() {
let def_id = tcx.hir.local_def_id(id);
symbols.push((ExportedSymbol::NonGeneric(def_id), SymbolExportLevel::C));
}
if let Some(_) = *tcx.sess.entry_fn.borrow() {
let symbol_name = "main".to_string();
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(&symbol_name));