@@ -168,7 +168,7 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
168168 tcx. reachable_non_generics ( def_id. krate ) . contains_key ( & def_id)
169169}
170170
171- fn exported_symbols_provider_local < ' tcx > (
171+ fn exported_non_generic_symbols_provider_local < ' tcx > (
172172 tcx : TyCtxt < ' tcx > ,
173173 _: LocalCrate ,
174174) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
@@ -306,6 +306,22 @@ fn exported_symbols_provider_local<'tcx>(
306306 ) ) ;
307307 }
308308
309+ // Sort so we get a stable incr. comp. hash.
310+ symbols. sort_by_cached_key ( |s| s. 0 . symbol_name_for_local_instance ( tcx) ) ;
311+
312+ tcx. arena . alloc_from_iter ( symbols)
313+ }
314+
315+ fn exported_generic_symbols_provider_local < ' tcx > (
316+ tcx : TyCtxt < ' tcx > ,
317+ _: LocalCrate ,
318+ ) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
319+ if !tcx. sess . opts . output_types . should_codegen ( ) && !tcx. is_sdylib_interface_build ( ) {
320+ return & [ ] ;
321+ }
322+
323+ let mut symbols: Vec < _ > = vec ! [ ] ;
324+
309325 if tcx. local_crate_exports_generics ( ) {
310326 use rustc_middle:: mir:: mono:: { Linkage , MonoItem , Visibility } ;
311327 use rustc_middle:: ty:: InstanceKind ;
@@ -474,7 +490,7 @@ fn upstream_monomorphizations_provider(
474490 let async_drop_in_place_fn_def_id = tcx. lang_items ( ) . async_drop_in_place_fn ( ) ;
475491
476492 for & cnum in cnums. iter ( ) {
477- for ( exported_symbol, _) in tcx. exported_symbols ( cnum) . iter ( ) {
493+ for ( exported_symbol, _) in tcx. exported_generic_symbols ( cnum) . iter ( ) {
478494 let ( def_id, args) = match * exported_symbol {
479495 ExportedSymbol :: Generic ( def_id, args) => ( def_id, args) ,
480496 ExportedSymbol :: DropGlue ( ty) => {
@@ -496,10 +512,7 @@ fn upstream_monomorphizations_provider(
496512 ExportedSymbol :: AsyncDropGlue ( def_id, ty) => ( def_id, tcx. mk_args ( & [ ty. into ( ) ] ) ) ,
497513 ExportedSymbol :: NonGeneric ( ..)
498514 | ExportedSymbol :: ThreadLocalShim ( ..)
499- | ExportedSymbol :: NoDefId ( ..) => {
500- // These are no monomorphizations
501- continue ;
502- }
515+ | ExportedSymbol :: NoDefId ( ..) => unreachable ! ( "{exported_symbol:?}" ) ,
503516 } ;
504517
505518 let args_map = instances. entry ( def_id) . or_default ( ) ;
@@ -554,7 +567,8 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
554567pub ( crate ) fn provide ( providers : & mut Providers ) {
555568 providers. reachable_non_generics = reachable_non_generics_provider;
556569 providers. is_reachable_non_generic = is_reachable_non_generic_provider_local;
557- providers. exported_symbols = exported_symbols_provider_local;
570+ providers. exported_non_generic_symbols = exported_non_generic_symbols_provider_local;
571+ providers. exported_generic_symbols = exported_generic_symbols_provider_local;
558572 providers. upstream_monomorphizations = upstream_monomorphizations_provider;
559573 providers. is_unreachable_local_definition = is_unreachable_local_definition_provider;
560574 providers. upstream_drop_glue_for = upstream_drop_glue_for_provider;
0 commit comments