Skip to content

Commit

Permalink
Fix export level of plugin and procmacro registrars.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Mar 6, 2018
1 parent 8bc005c commit 9f6d554
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
7 changes: 3 additions & 4 deletions src/librustc_metadata/cstore_impl.rs
Expand Up @@ -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())
}

Expand Down
20 changes: 11 additions & 9 deletions src/librustc_trans/back/symbol_export.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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| {
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 9f6d554

Please sign in to comment.