authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-02-12 08:36:15+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-02-12 08:36:15+01:00
log381e23146809b90de5a32f0fe1548c00b06e8ab2
tree6be8749cbee146f246bded4b0e66f3f15b4d75e2
parent13f31bb3c319813cbc3ed461ad9a97ec1c379f11
parenta6f64096a1487fa6787907d7f130dadff5decb5b

Merge pull request 'fix(codegen/llvm): teach llvm to not `dllexport` hidden exports' (#31180) from GasInfinity/zig:fix-hidden-dllexport into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31180 Reviewed-by: Alex Rønne Petersen <alex@alexrp.com>

2 files changed, 36 insertions(+), 28 deletions(-)

src/codegen/llvm.zig+2-2
...@@ -1735,7 +1735,7 @@ pub const Object = struct {...@@ -1735,7 +1735,7 @@ pub const Object = struct {
1735 }1735 }
17361736
1737 global_index.setUnnamedAddr(.default, &o.builder);1737 global_index.setUnnamedAddr(.default, &o.builder);
1738 if (comp.config.dll_export_fns)1738 if (comp.config.dll_export_fns and first_export.opts.visibility != .hidden)
1739 global_index.setDllStorageClass(.dllexport, &o.builder);1739 global_index.setDllStorageClass(.dllexport, &o.builder);
1740 global_index.setLinkage(switch (first_export.opts.linkage) {1740 global_index.setLinkage(switch (first_export.opts.linkage) {
1741 .internal => unreachable,1741 .internal => unreachable,
...@@ -1794,7 +1794,7 @@ pub const Object = struct {...@@ -1794,7 +1794,7 @@ pub const Object = struct {
17941794
1795 const alias_global_index = alias_index.ptrConst(&o.builder).global;1795 const alias_global_index = alias_index.ptrConst(&o.builder).global;
1796 alias_global_index.setUnnamedAddr(.default, &o.builder);1796 alias_global_index.setUnnamedAddr(.default, &o.builder);
1797 if (comp.config.dll_export_fns)1797 if (comp.config.dll_export_fns and first_export.opts.visibility != .hidden)
1798 alias_global_index.setDllStorageClass(.dllexport, &o.builder);1798 alias_global_index.setDllStorageClass(.dllexport, &o.builder);
1799 alias_global_index.setLinkage(switch (first_export.opts.linkage) {1799 alias_global_index.setLinkage(switch (first_export.opts.linkage) {
1800 .internal => unreachable,1800 .internal => unreachable,
test/standalone/shared_library/build.zig+34-26
...@@ -6,32 +6,40 @@ pub fn build(b: *std.Build) void {...@@ -6,32 +6,40 @@ pub fn build(b: *std.Build) void {
66
7 const optimize: std.builtin.OptimizeMode = .Debug;7 const optimize: std.builtin.OptimizeMode = .Debug;
8 const target = b.graph.host;8 const target = b.graph.host;
9 const lib = b.addLibrary(.{
10 .linkage = .dynamic,
11 .name = "mathtest",
12 .version = .{ .major = 1, .minor = 0, .patch = 0 },
13 .root_module = b.createModule(.{
14 .root_source_file = b.path("mathtest.zig"),
15 .target = target,
16 .optimize = optimize,
17 }),
18 });
199
20 const exe = b.addExecutable(.{10 const exe_names: []const []const u8 = &.{ "test", "test-dync" };
21 .name = "test",11 const lib_names: []const []const u8 = &.{ "mathtest", "mathtest-dync" };
22 .root_module = b.createModule(.{12 const lib_link_libc: []const bool = &.{ false, true };
23 .root_source_file = null,
24 .target = target,
25 .optimize = optimize,
26 .link_libc = true,
27 }),
28 });
29 exe.root_module.addCSourceFile(.{
30 .file = b.path("test.c"),
31 .flags = &[_][]const u8{"-std=c99"},
32 });
33 exe.root_module.linkLibrary(lib);
3413
35 const run_cmd = b.addRunArtifact(exe);14 for (exe_names, lib_names, lib_link_libc) |exe_name, lib_name, dyn_libc| {
36 test_step.dependOn(&run_cmd.step);15 const lib = b.addLibrary(.{
16 .linkage = .dynamic,
17 .name = lib_name,
18 .version = .{ .major = 1, .minor = 0, .patch = 0 },
19 .root_module = b.createModule(.{
20 .root_source_file = b.path("mathtest.zig"),
21 .target = target,
22 .optimize = optimize,
23 .link_libc = dyn_libc,
24 }),
25 });
26
27 const exe = b.addExecutable(.{
28 .name = exe_name,
29 .root_module = b.createModule(.{
30 .root_source_file = null,
31 .target = target,
32 .optimize = optimize,
33 .link_libc = true,
34 }),
35 });
36 exe.root_module.addCSourceFile(.{
37 .file = b.path("test.c"),
38 .flags = &[_][]const u8{"-std=c99"},
39 });
40 exe.root_module.linkLibrary(lib);
41
42 const run_cmd = b.addRunArtifact(exe);
43 test_step.dependOn(&run_cmd.step);
44 }
37}45}