diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-03-23 20:44:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-23 20:44:08 -0400 |
| commit | 9a243cf7d362a6d3bc64c2a9dec4a9199a8d561e (patch) | |
| tree | fc7a8f5825f4a595628ddba0e3ea5c3deecf79d3 /compiler/rustc_codegen_ssa/src | |
| parent | 95994f94ff5c9335426af4dec19afb5024f82fab (diff) | |
| parent | 530ab61c0eca891773bb71716849e3e934e84e9f (diff) | |
| download | rust-9a243cf7d362a6d3bc64c2a9dec4a9199a8d561e.tar.gz rust-9a243cf7d362a6d3bc64c2a9dec4a9199a8d561e.zip | |
Rollup merge of #137736 - bjorn3:compiler_builtins_export_fix, r=petrochenkov
Don't attempt to export compiler-builtins symbols from rust dylibs They are marked with hidden visibility to prevent them from getting exported, so we shouldn't ask the linker to export them anyway. The only thing that does it cause a warning on macOS. Part of https://github.com/rust-lang/rust/issues/136096 cc `@jyn514`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/linker.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/linker.rs b/compiler/rustc_codegen_ssa/src/back/linker.rs index e2a59c6efb8..3f5e0c1bce9 100644 --- a/compiler/rustc_codegen_ssa/src/back/linker.rs +++ b/compiler/rustc_codegen_ssa/src/back/linker.rs @@ -1782,7 +1782,10 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) - let mut symbols = Vec::new(); let export_threshold = symbol_export::crates_export_threshold(&[crate_type]); for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { - if info.level.is_below_threshold(export_threshold) { + // Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins + // from any cdylib. The latter doesn't work anyway as we use hidden visibility for + // compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning. + if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) { symbols.push(symbol_export::exporting_symbol_name_for_instance_in_crate( tcx, symbol, cnum, )); @@ -1821,7 +1824,9 @@ pub(crate) fn linked_symbols( let export_threshold = symbol_export::crates_export_threshold(&[crate_type]); for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| { - if info.level.is_below_threshold(export_threshold) || info.used { + if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) + || info.used + { symbols.push(( symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum), info.kind, |
