From 03f384f0217538c5408fae0794cde8afe1d0361c Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 28 Feb 2018 17:40:25 +0100 Subject: [PATCH] Fix export level of plugin and procmacro registrars. --- src/librustc_metadata/cstore_impl.rs | 7 +++---- src/librustc_trans/back/symbol_export.rs | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 4931eef585b0b..fe7d74bcdb5e9 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -257,10 +257,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()) } diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index 7ff3c71278988..9b5e01f2fd991 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -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));