wasm linker: change rules about symbol visibility
export by default means export, as expected. if you want hidden visibility then use hidden visibility.
This commit is contained in:
@@ -11,7 +11,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
|
||||
const no_export = b.addExecutable(.{
|
||||
.name = "no-export",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("main.zig"),
|
||||
.root_source_file = b.path("main-hidden.zig"),
|
||||
.optimize = optimize,
|
||||
.target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
|
||||
}),
|
||||
@@ -36,7 +36,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
|
||||
const force_export = b.addExecutable(.{
|
||||
.name = "force",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("main.zig"),
|
||||
.root_source_file = b.path("main-hidden.zig"),
|
||||
.optimize = optimize,
|
||||
.target = b.resolveTargetQuery(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }),
|
||||
}),
|
||||
|
||||
4
test/link/wasm/export/main-hidden.zig
Normal file
4
test/link/wasm/export/main-hidden.zig
Normal file
@@ -0,0 +1,4 @@
|
||||
fn foo() callconv(.c) void {}
|
||||
comptime {
|
||||
@export(&foo, .{ .name = "foo", .visibility = .hidden });
|
||||
}
|
||||
@@ -40,7 +40,7 @@ fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.Optimize
|
||||
|
||||
check_export.checkInHeaders();
|
||||
check_export.checkExact("Section export");
|
||||
check_export.checkExact("entries 2");
|
||||
check_export.checkExact("entries 3");
|
||||
check_export.checkExact("name __indirect_function_table"); // as per linker specification
|
||||
check_export.checkExact("kind table");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user