Move metadata symbol export from exported_non_generic_symbols to exported_symbols
The metadata symbol must not be encoded in the crate metadata, and must be exported from proc-macros. Handling the export of the metadata symbol in exported_symbols handles both things at once without requiring manual fixups elsewhere.
This commit is contained in:
parent
9b1a30e5e6
commit
186cef0f51
3 changed files with 12 additions and 38 deletions
|
|
@ -1805,11 +1805,18 @@ pub(crate) fn exported_symbols(
|
|||
.collect();
|
||||
}
|
||||
|
||||
if let CrateType::ProcMacro = crate_type {
|
||||
let mut symbols = if let CrateType::ProcMacro = crate_type {
|
||||
exported_symbols_for_proc_macro_crate(tcx)
|
||||
} else {
|
||||
exported_symbols_for_non_proc_macro(tcx, crate_type)
|
||||
};
|
||||
|
||||
if crate_type == CrateType::Dylib || crate_type == CrateType::ProcMacro {
|
||||
let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
|
||||
symbols.push((metadata_symbol_name, SymbolExportKind::Data));
|
||||
}
|
||||
|
||||
symbols
|
||||
}
|
||||
|
||||
fn exported_symbols_for_non_proc_macro(
|
||||
|
|
@ -1842,12 +1849,8 @@ fn exported_symbols_for_proc_macro_crate(tcx: TyCtxt<'_>) -> Vec<(String, Symbol
|
|||
|
||||
let stable_crate_id = tcx.stable_crate_id(LOCAL_CRATE);
|
||||
let proc_macro_decls_name = tcx.sess.generate_proc_macro_decls_symbol(stable_crate_id);
|
||||
let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
|
||||
|
||||
vec![
|
||||
(proc_macro_decls_name, SymbolExportKind::Data),
|
||||
(metadata_symbol_name, SymbolExportKind::Data),
|
||||
]
|
||||
vec![(proc_macro_decls_name, SymbolExportKind::Data)]
|
||||
}
|
||||
|
||||
pub(crate) fn linked_symbols(
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LOCAL_CRATE, LocalDefId};
|
|||
use rustc_middle::bug;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::exported_symbols::{
|
||||
ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel, metadata_symbol_name,
|
||||
ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
|
||||
};
|
||||
use rustc_middle::query::LocalCrate;
|
||||
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, Ty, TyCtxt};
|
||||
|
|
@ -289,23 +289,6 @@ fn exported_non_generic_symbols_provider_local<'tcx>(
|
|||
}));
|
||||
}
|
||||
|
||||
if tcx.crate_types().contains(&CrateType::Dylib)
|
||||
|| tcx.crate_types().contains(&CrateType::ProcMacro)
|
||||
{
|
||||
let symbol_name = metadata_symbol_name(tcx);
|
||||
let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name));
|
||||
|
||||
symbols.push((
|
||||
exported_symbol,
|
||||
SymbolExportInfo {
|
||||
level: SymbolExportLevel::C,
|
||||
kind: SymbolExportKind::Data,
|
||||
used: true,
|
||||
rustc_std_internal_symbol: false,
|
||||
},
|
||||
));
|
||||
}
|
||||
|
||||
// Sort so we get a stable incr. comp. hash.
|
||||
symbols.sort_by_cached_key(|s| s.0.symbol_name_for_local_instance(tcx));
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,12 @@ use rustc_hir::find_attr;
|
|||
use rustc_hir_pretty::id_to_string;
|
||||
use rustc_middle::dep_graph::WorkProductId;
|
||||
use rustc_middle::middle::dependency_format::Linkage;
|
||||
use rustc_middle::middle::exported_symbols::metadata_symbol_name;
|
||||
use rustc_middle::mir::interpret;
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::traits::specialization_graph;
|
||||
use rustc_middle::ty::AssocItemContainer;
|
||||
use rustc_middle::ty::codec::TyEncoder;
|
||||
use rustc_middle::ty::fast_reject::{self, TreatParams};
|
||||
use rustc_middle::ty::{AssocItemContainer, SymbolName};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque};
|
||||
use rustc_session::config::{CrateType, OptLevel, TargetModifier};
|
||||
|
|
@ -2207,19 +2206,8 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
exported_symbols: &[(ExportedSymbol<'tcx>, SymbolExportInfo)],
|
||||
) -> LazyArray<(ExportedSymbol<'static>, SymbolExportInfo)> {
|
||||
empty_proc_macro!(self);
|
||||
// The metadata symbol name is special. It should not show up in
|
||||
// downstream crates.
|
||||
let metadata_symbol_name = SymbolName::new(self.tcx, &metadata_symbol_name(self.tcx));
|
||||
|
||||
self.lazy_array(
|
||||
exported_symbols
|
||||
.iter()
|
||||
.filter(|&(exported_symbol, _)| match *exported_symbol {
|
||||
ExportedSymbol::NoDefId(symbol_name) => symbol_name != metadata_symbol_name,
|
||||
_ => true,
|
||||
})
|
||||
.cloned(),
|
||||
)
|
||||
self.lazy_array(exported_symbols.iter().cloned())
|
||||
}
|
||||
|
||||
fn encode_dylib_dependency_formats(&mut self) -> LazyArray<Option<LinkagePreference>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue