| author | |
| committer | |
| log | ef0df24626cc6c3cfe0b87164d481eeb26cc57fb |
| tree | 54da3ca8bd51daa0858fa00f49dcae3885647abd |
| parent | 66bcc55e0196bd43746a09a79668c7c495bd1f89 |
| signature |
This adds a simple linker test to ensure the built library contains
an import entry for each extern function call that was mangled.5 files changed, 37 insertions(+), 0 deletions(-)
test/link.zig+5| ... | ... | @@ -48,6 +48,11 @@ fn addWasmCases(cases: *tests.StandaloneContext) void { |
| 48 | 48 | .use_emulation = true, |
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | cases.addBuildFile("test/link/wasm/extern-mangle/build.zig", .{ | |
| 52 | .build_modes = true, | |
| 53 | .requires_stage2 = true, | |
| 54 | }); | |
| 55 | ||
| 51 | 56 | cases.addBuildFile("test/link/wasm/infer-features/build.zig", .{ |
| 52 | 57 | .requires_stage2 = true, |
| 53 | 58 | }); |
test/link/wasm/extern-mangle/a.zig created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | pub extern "a" fn hello() i32; |
test/link/wasm/extern-mangle/b.zig created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | pub extern "b" fn hello() i32; |
test/link/wasm/extern-mangle/build.zig created+24| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | const std = @import("std"); | |
| 2 | const Builder = std.build.Builder; | |
| 3 | ||
| 4 | pub fn build(b: *Builder) void { | |
| 5 | const mode = b.standardReleaseOptions(); | |
| 6 | ||
| 7 | const test_step = b.step("test", "Test"); | |
| 8 | test_step.dependOn(b.getInstallStep()); | |
| 9 | ||
| 10 | const lib = b.addSharedLibrary("lib", "lib.zig", .unversioned); | |
| 11 | lib.setBuildMode(mode); | |
| 12 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | |
| 13 | lib.install(); | |
| 14 | ||
| 15 | const check_lib = lib.checkObject(.wasm); | |
| 16 | check_lib.checkStart("Section import"); | |
| 17 | check_lib.checkNext("entries 2"); // a.hello & b.hello | |
| 18 | check_lib.checkNext("module a"); | |
| 19 | check_lib.checkNext("name hello"); | |
| 20 | check_lib.checkNext("module b"); | |
| 21 | check_lib.checkNext("name hello"); | |
| 22 | ||
| 23 | test_step.dependOn(&check_lib.step); | |
| 24 | } |
test/link/wasm/extern-mangle/lib.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | const a = @import("a.zig").hello; | |
| 2 | const b = @import("b.zig").hello; | |
| 3 | export fn foo() void { | |
| 4 | _ = a(); | |
| 5 | _ = b(); | |
| 6 | } |