forked from ziglang/zig
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test/link: add linker test to verify mangling
This adds a simple linker test to ensure the built library contains an import entry for each extern function call that was mangled.
- Loading branch information
1 parent
66bcc55
commit ef0df24
Showing
5 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub extern "a" fn hello() i32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub extern "b" fn hello() i32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const std = @import("std"); | ||
const Builder = std.build.Builder; | ||
|
||
pub fn build(b: *Builder) void { | ||
const mode = b.standardReleaseOptions(); | ||
|
||
const test_step = b.step("test", "Test"); | ||
test_step.dependOn(b.getInstallStep()); | ||
|
||
const lib = b.addSharedLibrary("lib", "lib.zig", .unversioned); | ||
lib.setBuildMode(mode); | ||
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | ||
lib.install(); | ||
|
||
const check_lib = lib.checkObject(.wasm); | ||
check_lib.checkStart("Section import"); | ||
check_lib.checkNext("entries 2"); // a.hello & b.hello | ||
check_lib.checkNext("module a"); | ||
check_lib.checkNext("name hello"); | ||
check_lib.checkNext("module b"); | ||
check_lib.checkNext("name hello"); | ||
|
||
test_step.dependOn(&check_lib.step); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const a = @import("a.zig").hello; | ||
const b = @import("b.zig").hello; | ||
export fn foo() void { | ||
_ = a(); | ||
_ = b(); | ||
} |