| author | |
| committer | |
| log | 744bb5d16a1acdabb7c078f7a1a30eefeac733cc |
| tree | ba6e043f65776159680f703dd48b63da7e94a37e |
| parent | dcb4134835e0c0bb0c130731efec741b41aba522 |
export by default means export, as expected. if you want hidden
visibility then use hidden visibility.5 files changed, 9 insertions(+), 6 deletions(-)
src/link/Wasm.zig+1-1| ... | @@ -3502,7 +3502,7 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex, override_export: bool) link | ... | @@ -3502,7 +3502,7 @@ fn markFunction(wasm: *Wasm, i: ObjectFunctionIndex, override_export: bool) link |
| 3502 | 3502 | ||
| 3503 | if (!is_obj and (override_export or function.flags.isExported(rdynamic))) { | 3503 | if (!is_obj and (override_export or function.flags.isExported(rdynamic))) { |
| 3504 | const symbol_name = function.name.unwrap().?; | 3504 | const symbol_name = function.name.unwrap().?; |
| 3505 | if (function.flags.visibility_hidden) { | 3505 | if (!override_export and function.flags.visibility_hidden) { |
| 3506 | try wasm.hidden_function_exports.put(gpa, symbol_name, @enumFromInt(gop.index)); | 3506 | try wasm.hidden_function_exports.put(gpa, symbol_name, @enumFromInt(gop.index)); |
| 3507 | } else { | 3507 | } else { |
| 3508 | try wasm.function_exports.put(gpa, symbol_name, @enumFromInt(gop.index)); | 3508 | try wasm.function_exports.put(gpa, symbol_name, @enumFromInt(gop.index)); |
src/link/Wasm/Flush.zig+1-2| ... | @@ -210,9 +210,8 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { | ... | @@ -210,9 +210,8 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void { |
| 210 | const function_index = Wasm.FunctionIndex.fromIpNav(wasm, nav_export.nav_index).?; | 210 | const function_index = Wasm.FunctionIndex.fromIpNav(wasm, nav_export.nav_index).?; |
| 211 | const explicit = f.missing_exports.swapRemove(nav_export.name); | 211 | const explicit = f.missing_exports.swapRemove(nav_export.name); |
| 212 | const is_hidden = !explicit and switch (export_index.ptr(zcu).opts.visibility) { | 212 | const is_hidden = !explicit and switch (export_index.ptr(zcu).opts.visibility) { |
| 213 | .protected => false, | ||
| 214 | .hidden => true, | 213 | .hidden => true, |
| 215 | .default => !comp.config.rdynamic, | 214 | .default, .protected => false, |
| 216 | }; | 215 | }; |
| 217 | if (is_hidden) { | 216 | if (is_hidden) { |
| 218 | try wasm.hidden_function_exports.put(gpa, nav_export.name, function_index); | 217 | try wasm.hidden_function_exports.put(gpa, nav_export.name, function_index); |
test/link/wasm/export/build.zig+2-2| ... | @@ -11,7 +11,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize | ... | @@ -11,7 +11,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 11 | const no_export = b.addExecutable(.{ | 11 | const no_export = b.addExecutable(.{ |
| 12 | .name = "no-export", | 12 | .name = "no-export", |
| 13 | .root_module = b.createModule(.{ | 13 | .root_module = b.createModule(.{ |
| 14 | .root_source_file = b.path("main.zig"), | 14 | .root_source_file = b.path("main-hidden.zig"), |
| 15 | .optimize = optimize, | 15 | .optimize = optimize, |
| 16 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), | 16 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), |
| 17 | }), | 17 | }), |
| ... | @@ -36,7 +36,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize | ... | @@ -36,7 +36,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 36 | const force_export = b.addExecutable(.{ | 36 | const force_export = b.addExecutable(.{ |
| 37 | .name = "force", | 37 | .name = "force", |
| 38 | .root_module = b.createModule(.{ | 38 | .root_module = b.createModule(.{ |
| 39 | .root_source_file = b.path("main.zig"), | 39 | .root_source_file = b.path("main-hidden.zig"), |
| 40 | .optimize = optimize, | 40 | .optimize = optimize, |
| 41 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), | 41 | .target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }), |
| 42 | }), | 42 | }), |
test/link/wasm/export/main-hidden.zig created+4| ... | @@ -0,0 +1,4 @@ | ||
| 1 | fn foo() callconv(.c) void {} | ||
| 2 | comptime { | ||
| 3 | @export(&foo, .{ .name = "foo", .visibility = .hidden }); | ||
| 4 | } | ||
test/link/wasm/function-table/build.zig+1-1| ... | @@ -40,7 +40,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize | ... | @@ -40,7 +40,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize |
| 40 | 40 | ||
| 41 | check_export.checkInHeaders(); | 41 | check_export.checkInHeaders(); |
| 42 | check_export.checkExact("Section export"); | 42 | check_export.checkExact("Section export"); |
| 43 | check_export.checkExact("entries 2"); | 43 | check_export.checkExact("entries 3"); |
| 44 | check_export.checkExact("name __indirect_function_table"); // as per linker specification | 44 | check_export.checkExact("name __indirect_function_table"); // as per linker specification |
| 45 | check_export.checkExact("kind table"); | 45 | check_export.checkExact("kind table"); |
| 46 | 46 |