@@ -164,7 +164,7 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
164164 tcx. reachable_non_generics ( def_id. krate ) . contains_key ( & def_id)
165165}
166166
167- fn exported_symbols_provider_local < ' tcx > (
167+ fn exported_non_generic_symbols_provider_local < ' tcx > (
168168 tcx : TyCtxt < ' tcx > ,
169169 _: LocalCrate ,
170170) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
@@ -296,6 +296,22 @@ fn exported_symbols_provider_local<'tcx>(
296296 ) ) ;
297297 }
298298
299+ // Sort so we get a stable incr. comp. hash.
300+ symbols. sort_by_cached_key ( |s| s. 0 . symbol_name_for_local_instance ( tcx) ) ;
301+
302+ tcx. arena . alloc_from_iter ( symbols)
303+ }
304+
305+ fn exported_generic_symbols_provider_local < ' tcx > (
306+ tcx : TyCtxt < ' tcx > ,
307+ _: LocalCrate ,
308+ ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
309+ if !tcx. sess . opts . output_types . should_codegen ( ) && !tcx. is_sdylib_interface_build ( ) {
310+ return & [ ] ;
311+ }
312+
313+ let mut symbols: Vec < _ > = vec ! [ ] ;
314+
299315 if tcx. local_crate_exports_generics ( ) {
300316 use rustc_middle:: mir:: mono:: { Linkage , MonoItem , Visibility } ;
301317 use rustc_middle:: ty:: InstanceKind ;
@@ -458,7 +474,7 @@ fn upstream_monomorphizations_provider(
458474 let async_drop_in_place_fn_def_id = tcx. lang_items ( ) . async_drop_in_place_fn ( ) ;
459475
460476 for & cnum in cnums. iter ( ) {
461- for ( exported_symbol, _) in tcx. exported_symbols ( cnum) . iter ( ) {
477+ for ( exported_symbol, _) in tcx. exported_generic_symbols ( cnum) . iter ( ) {
462478 let ( def_id, args) = match * exported_symbol {
463479 ExportedSymbol :: Generic ( def_id, args) => ( def_id, args) ,
464480 ExportedSymbol :: DropGlue ( ty) => {
@@ -480,10 +496,7 @@ fn upstream_monomorphizations_provider(
480496 ExportedSymbol :: AsyncDropGlue ( def_id, ty) => ( def_id, tcx. mk_args ( & [ ty. into ( ) ] ) ) ,
481497 ExportedSymbol :: NonGeneric ( ..)
482498 | ExportedSymbol :: ThreadLocalShim ( ..)
483- | ExportedSymbol :: NoDefId ( ..) => {
484- // These are no monomorphizations
485- continue ;
486- }
499+ | ExportedSymbol :: NoDefId ( ..) => unreachable ! ( "{exported_symbol:?}" ) ,
487500 } ;
488501
489502 let args_map = instances. entry ( def_id) . or_default ( ) ;
@@ -538,7 +551,8 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
538551pub ( crate ) fn provide ( providers : & mut Providers ) {
539552 providers. reachable_non_generics = reachable_non_generics_provider;
540553 providers. is_reachable_non_generic = is_reachable_non_generic_provider_local;
541- providers. exported_symbols = exported_symbols_provider_local;
554+ providers. exported_non_generic_symbols = exported_non_generic_symbols_provider_local;
555+ providers. exported_generic_symbols = exported_generic_symbols_provider_local;
542556 providers. upstream_monomorphizations = upstream_monomorphizations_provider;
543557 providers. is_unreachable_local_definition = is_unreachable_local_definition_provider;
544558 providers. upstream_drop_glue_for = upstream_drop_glue_for_provider;
0 commit comments