test/link: update linker tests

Force importing symbols to show the correct functions are being
imported from the host environment.
This commit is contained in:
Luuk de Gram 2022-12-28 16:36:46 +01:00
parent 4bffe645c6
commit 8403612adc
No known key found for this signature in database
GPG Key ID: A8CFE58E4DC7D664
2 changed files with 3 additions and 1 deletions

View File

@ -3443,7 +3443,7 @@ fn linkWithLLD(wasm: *Wasm, comp: *Compilation, prog_node: *std.Progress.Node) !
try argv.append("--no-entry"); // So lld doesn't look for _start.
}
if (wasm.base.options.import_symbols) {
try argv.appendSlice(&[_][]const u8{"--allow-undefined"});
try argv.append("--allow-undefined");
}
try argv.appendSlice(&[_][]const u8{
"-o",

View File

@ -10,6 +10,8 @@ pub fn build(b: *Builder) void {
const lib = b.addSharedLibrary("lib", "lib.zig", .unversioned);
lib.setBuildMode(mode);
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
lib.import_symbols = true; // import `a` and `b`
lib.rdynamic = true; // export `foo`
lib.install();
const check_lib = lib.checkObject(.wasm);