From 092352ec63d3a4e9ff59a5d8ad8f119bf0eda468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 18 May 2025 20:55:56 +0200 Subject: [PATCH] compiler-rt, zigc: Use hidden visibility except when testing. This prevents symbols from these libraries from polluting the dynamic symbol tables of binaries built with Zig. The downside is that we no longer deduplicate the symbols at run time due to weak linkage. Closes #7935. Closes #13303. Closes #19342. --- lib/c/common.zig | 2 +- lib/compiler_rt/common.zig | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/c/common.zig b/lib/c/common.zig index e9536f63b4..4419b65cc6 100644 --- a/lib/c/common.zig +++ b/lib/c/common.zig @@ -9,7 +9,7 @@ else /// Determines the symbol's visibility to other objects. /// For WebAssembly this allows the symbol to be resolved to other modules, but will not /// export it to the host runtime. -pub const visibility: std.builtin.SymbolVisibility = if (builtin.cpu.arch.isWasm() and linkage != .internal) +pub const visibility: std.builtin.SymbolVisibility = if (linkage != .internal) .hidden else .default; diff --git a/lib/compiler_rt/common.zig b/lib/compiler_rt/common.zig index 28707d720a..4a38c1ca2d 100644 --- a/lib/compiler_rt/common.zig +++ b/lib/compiler_rt/common.zig @@ -13,8 +13,10 @@ else /// Determines the symbol's visibility to other objects. /// For WebAssembly this allows the symbol to be resolved to other modules, but will not /// export it to the host runtime. -pub const visibility: std.builtin.SymbolVisibility = - if (builtin.target.cpu.arch.isWasm() and linkage != .internal) .hidden else .default; +pub const visibility: std.builtin.SymbolVisibility = if (linkage != .internal) + .hidden +else + .default; pub const PreferredLoadStoreElement = element: { if (std.simd.suggestVectorLength(u8)) |vec_size| {