@@ -168,7 +168,7 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
168
168
tcx. reachable_non_generics ( def_id. krate ) . contains_key ( & def_id)
169
169
}
170
170
171
- fn exported_symbols_provider_local < ' tcx > (
171
+ fn exported_non_generic_symbols_provider_local < ' tcx > (
172
172
tcx : TyCtxt < ' tcx > ,
173
173
_: LocalCrate ,
174
174
) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
@@ -306,6 +306,22 @@ fn exported_symbols_provider_local<'tcx>(
306
306
) ) ;
307
307
}
308
308
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
+
309
325
if tcx. local_crate_exports_generics ( ) {
310
326
use rustc_middle:: mir:: mono:: { Linkage , MonoItem , Visibility } ;
311
327
use rustc_middle:: ty:: InstanceKind ;
@@ -474,7 +490,7 @@ fn upstream_monomorphizations_provider(
474
490
let async_drop_in_place_fn_def_id = tcx. lang_items ( ) . async_drop_in_place_fn ( ) ;
475
491
476
492
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 ( ) {
478
494
let ( def_id, args) = match * exported_symbol {
479
495
ExportedSymbol :: Generic ( def_id, args) => ( def_id, args) ,
480
496
ExportedSymbol :: DropGlue ( ty) => {
@@ -496,10 +512,7 @@ fn upstream_monomorphizations_provider(
496
512
ExportedSymbol :: AsyncDropGlue ( def_id, ty) => ( def_id, tcx. mk_args ( & [ ty. into ( ) ] ) ) ,
497
513
ExportedSymbol :: NonGeneric ( ..)
498
514
| ExportedSymbol :: ThreadLocalShim ( ..)
499
- | ExportedSymbol :: NoDefId ( ..) => {
500
- // These are no monomorphizations
501
- continue ;
502
- }
515
+ | ExportedSymbol :: NoDefId ( ..) => unreachable ! ( "{exported_symbol:?}" ) ,
503
516
} ;
504
517
505
518
let args_map = instances. entry ( def_id) . or_default ( ) ;
@@ -554,7 +567,8 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
554
567
pub ( crate ) fn provide ( providers : & mut Providers ) {
555
568
providers. reachable_non_generics = reachable_non_generics_provider;
556
569
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;
558
572
providers. upstream_monomorphizations = upstream_monomorphizations_provider;
559
573
providers. is_unreachable_local_definition = is_unreachable_local_definition_provider;
560
574
providers. upstream_drop_glue_for = upstream_drop_glue_for_provider;
0 commit comments