Skip to content

Commit 5014353

Browse files
committed
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.
1 parent 96cfc75 commit 5014353

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,10 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) -
17841784
let mut symbols = Vec::new();
17851785
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
17861786
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
1787-
if info.level.is_below_threshold(export_threshold) {
1787+
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
1788+
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
1789+
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
1790+
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
17881791
symbols.push(symbol_export::exporting_symbol_name_for_instance_in_crate(
17891792
tcx, symbol, cnum,
17901793
));

0 commit comments

Comments
 (0)