mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
test/link: add wasm linker-test for archives
Adds a test case that will pull-in compiler-rt symbols, and therefore link with the compiler-rt archive file.
This commit is contained in:
parent
1544625df3
commit
7fe2a3d104
@ -1898,12 +1898,7 @@ pub const LibExeObjStep = struct {
|
||||
pub fn runEmulatable(exe: *LibExeObjStep) *EmulatableRunStep {
|
||||
assert(exe.kind == .exe or exe.kind == .test_exe);
|
||||
|
||||
const run_step = EmulatableRunStep.create(exe.builder.fmt("run {s}", .{exe.step.name}), exe);
|
||||
if (exe.vcpkg_bin_path) |path| {
|
||||
run_step.addPathDir(path);
|
||||
}
|
||||
|
||||
return run_step;
|
||||
return EmulatableRunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name}), exe);
|
||||
}
|
||||
|
||||
pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
|
||||
|
||||
@ -47,6 +47,11 @@ fn addWasmCases(cases: *tests.StandaloneContext) void {
|
||||
.build_modes = true,
|
||||
.requires_stage2 = true,
|
||||
});
|
||||
|
||||
cases.addBuildFile("test/link/wasm/archive/build.zig", .{
|
||||
.build_modes = true,
|
||||
.requires_stage2 = true,
|
||||
});
|
||||
}
|
||||
|
||||
fn addMachOCases(cases: *tests.StandaloneContext) void {
|
||||
|
||||
27
test/link/wasm/archive/build.zig
Normal file
27
test/link/wasm/archive/build.zig
Normal file
@ -0,0 +1,27 @@
|
||||
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());
|
||||
|
||||
// The code in question will pull-in compiler-rt,
|
||||
// and therefore link with its archive file.
|
||||
const lib = b.addSharedLibrary("main", "main.zig", .unversioned);
|
||||
lib.setBuildMode(mode);
|
||||
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
|
||||
lib.use_llvm = false;
|
||||
lib.use_stage1 = false;
|
||||
lib.use_lld = false;
|
||||
|
||||
const check = lib.checkObject(.wasm);
|
||||
check.checkStart("Section import");
|
||||
check.checkNext("entries 1"); // __truncsfhf2 should have been resolved, so only 1 import (compiler-rt's memcpy).
|
||||
|
||||
check.checkStart("Section custom");
|
||||
check.checkNext("name __truncsfhf2"); // Ensure it was imported and resolved
|
||||
|
||||
test_step.dependOn(&check.step);
|
||||
}
|
||||
6
test/link/wasm/archive/main.zig
Normal file
6
test/link/wasm/archive/main.zig
Normal file
@ -0,0 +1,6 @@
|
||||
export fn foo() void {
|
||||
var a: f16 = 2.2;
|
||||
// this will pull-in compiler-rt
|
||||
var b = @trunc(a);
|
||||
_ = b;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user