@@ -51,15 +51,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
5151 return Default :: default ( ) ;
5252 }
5353
54- // Check to see if this crate is a "special runtime crate". These
55- // crates, implementation details of the standard library, typically
56- // have a bunch of `pub extern` and `#[no_mangle]` functions as the
57- // ABI between them. We don't want their symbols to have a `C`
58- // export level, however, as they're just implementation details.
59- // Down below we'll hardwire all of the symbols to the `Rust` export
60- // level instead.
61- let special_runtime_crate =
62- tcx. is_panic_runtime ( LOCAL_CRATE ) || tcx. is_compiler_builtins ( LOCAL_CRATE ) ;
54+ let is_compiler_builtins = tcx. is_compiler_builtins ( LOCAL_CRATE ) ;
6355
6456 let mut reachable_non_generics: DefIdMap < _ > = tcx
6557 . reachable_set ( ( ) )
@@ -104,11 +96,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
10496 if tcx. cross_crate_inlinable ( def_id) { None } else { Some ( def_id) }
10597 } )
10698 . map ( |def_id| {
107- // We won't link right if this symbol is stripped during LTO.
108- let name = tcx. symbol_name ( Instance :: mono ( tcx, def_id. to_def_id ( ) ) ) . name ;
109- let used = name == "rust_eh_personality" ;
110-
111- let export_level = if special_runtime_crate {
99+ let export_level = if is_compiler_builtins {
100+ // We don't want to export compiler-builtins symbols from any
101+ // dylibs, even rust dylibs. Unlike all other crates it gets
102+ // duplicated in every linker invocation and it may otherwise
103+ // unintentionally override definitions of these symbols by
104+ // libgcc or compiler-rt for C code.
112105 SymbolExportLevel :: Rust
113106 } else {
114107 symbol_export_level ( tcx, def_id. to_def_id ( ) )
@@ -131,8 +124,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap<S
131124 SymbolExportKind :: Text
132125 } ,
133126 used : codegen_attrs. flags . contains ( CodegenFnAttrFlags :: USED_COMPILER )
134- || codegen_attrs. flags . contains ( CodegenFnAttrFlags :: USED_LINKER )
135- || used,
127+ || codegen_attrs. flags . contains ( CodegenFnAttrFlags :: USED_LINKER ) ,
136128 rustc_std_internal_symbol : codegen_attrs
137129 . flags
138130 . contains ( CodegenFnAttrFlags :: RUSTC_STD_INTERNAL_SYMBOL ) ,
0 commit comments