Skip to content

Commit c49fce8

Browse files
committed
Auto merge of rust-lang#137736 - bjorn3:compiler_builtins_export_fix, r=<try>
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 rust-lang#136096 cc `@jyn514` try-job: dist-aarch64-msvc
2 parents 4ac032f + 530ab61 commit c49fce8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

compiler/rustc_codegen_ssa/src/back/linker.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,10 @@ fn exported_symbols_for_non_proc_macro(tcx: TyCtxt<'_>, crate_type: CrateType) -
17821782
let mut symbols = Vec::new();
17831783
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
17841784
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
1785-
if info.level.is_below_threshold(export_threshold) {
1785+
// Do not export mangled symbols from cdylibs and don't attempt to export compiler-builtins
1786+
// from any cdylib. The latter doesn't work anyway as we use hidden visibility for
1787+
// compiler-builtins. Most linkers silently ignore it, but ld64 gives a warning.
1788+
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum) {
17861789
symbols.push(symbol_export::exporting_symbol_name_for_instance_in_crate(
17871790
tcx, symbol, cnum,
17881791
));
@@ -1821,7 +1824,9 @@ pub(crate) fn linked_symbols(
18211824

18221825
let export_threshold = symbol_export::crates_export_threshold(&[crate_type]);
18231826
for_each_exported_symbols_include_dep(tcx, crate_type, |symbol, info, cnum| {
1824-
if info.level.is_below_threshold(export_threshold) || info.used {
1827+
if info.level.is_below_threshold(export_threshold) && !tcx.is_compiler_builtins(cnum)
1828+
|| info.used
1829+
{
18251830
symbols.push((
18261831
symbol_export::linking_symbol_name_for_instance_in_crate(tcx, symbol, cnum),
18271832
info.kind,

0 commit comments

Comments
 (0)