@@ -164,7 +164,7 @@ fn is_reachable_non_generic_provider_extern(tcx: TyCtxt<'_>, def_id: DefId) -> b
164
164
tcx. reachable_non_generics ( def_id. krate ) . contains_key ( & def_id)
165
165
}
166
166
167
- fn exported_symbols_provider_local < ' tcx > (
167
+ fn exported_non_generic_symbols_provider_local < ' tcx > (
168
168
tcx : TyCtxt < ' tcx > ,
169
169
_: LocalCrate ,
170
170
) -> & ' tcx [ ( ExportedSymbol < ' tcx > , SymbolExportInfo ) ] {
@@ -296,6 +296,22 @@ fn exported_symbols_provider_local<'tcx>(
296
296
) ) ;
297
297
}
298
298
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
+
299
315
if tcx. local_crate_exports_generics ( ) {
300
316
use rustc_middle:: mir:: mono:: { Linkage , MonoItem , Visibility } ;
301
317
use rustc_middle:: ty:: InstanceKind ;
@@ -458,7 +474,7 @@ fn upstream_monomorphizations_provider(
458
474
let async_drop_in_place_fn_def_id = tcx. lang_items ( ) . async_drop_in_place_fn ( ) ;
459
475
460
476
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 ( ) {
462
478
let ( def_id, args) = match * exported_symbol {
463
479
ExportedSymbol :: Generic ( def_id, args) => ( def_id, args) ,
464
480
ExportedSymbol :: DropGlue ( ty) => {
@@ -480,10 +496,7 @@ fn upstream_monomorphizations_provider(
480
496
ExportedSymbol :: AsyncDropGlue ( def_id, ty) => ( def_id, tcx. mk_args ( & [ ty. into ( ) ] ) ) ,
481
497
ExportedSymbol :: NonGeneric ( ..)
482
498
| ExportedSymbol :: ThreadLocalShim ( ..)
483
- | ExportedSymbol :: NoDefId ( ..) => {
484
- // These are no monomorphizations
485
- continue ;
486
- }
499
+ | ExportedSymbol :: NoDefId ( ..) => unreachable ! ( "{exported_symbol:?}" ) ,
487
500
} ;
488
501
489
502
let args_map = instances. entry ( def_id) . or_default ( ) ;
@@ -538,7 +551,8 @@ fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId)
538
551
pub ( crate ) fn provide ( providers : & mut Providers ) {
539
552
providers. reachable_non_generics = reachable_non_generics_provider;
540
553
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;
542
556
providers. upstream_monomorphizations = upstream_monomorphizations_provider;
543
557
providers. is_unreachable_local_definition = is_unreachable_local_definition_provider;
544
558
providers. upstream_drop_glue_for = upstream_drop_glue_for_provider;
0 commit comments