| author | |
| committer | |
| log | 7fe2a3d104319835127456d02ba73efc5fe5f207 |
| tree | 5a46464ed29f8e4f5a0654f9adeb3aaa9e10a8ac |
| parent | 1544625df3fb4732f2cd63d1e7c4c738d1b7d0c0 |
| signature |
Adds a test case that will pull-in compiler-rt symbols,
and therefore link with the compiler-rt archive file.4 files changed, 39 insertions(+), 6 deletions(-)
lib/std/build.zig+1-6| ... | ... | @@ -1898,12 +1898,7 @@ pub const LibExeObjStep = struct { |
| 1898 | 1898 | pub fn runEmulatable(exe: *LibExeObjStep) *EmulatableRunStep { |
| 1899 | 1899 | assert(exe.kind == .exe or exe.kind == .test_exe); |
| 1900 | 1900 | |
| 1901 | const run_step = EmulatableRunStep.create(exe.builder.fmt("run {s}", .{exe.step.name}), exe); | |
| 1902 | if (exe.vcpkg_bin_path) |path| { | |
| 1903 | run_step.addPathDir(path); | |
| 1904 | } | |
| 1905 | ||
| 1906 | return run_step; | |
| 1901 | return EmulatableRunStep.create(exe.builder, exe.builder.fmt("run {s}", .{exe.step.name}), exe); | |
| 1907 | 1902 | } |
| 1908 | 1903 | |
| 1909 | 1904 | pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep { |
test/link.zig+5| ... | ... | @@ -47,6 +47,11 @@ fn addWasmCases(cases: *tests.StandaloneContext) void { |
| 47 | 47 | .build_modes = true, |
| 48 | 48 | .requires_stage2 = true, |
| 49 | 49 | }); |
| 50 | ||
| 51 | cases.addBuildFile("test/link/wasm/archive/build.zig", .{ | |
| 52 | .build_modes = true, | |
| 53 | .requires_stage2 = true, | |
| 54 | }); | |
| 50 | 55 | } |
| 51 | 56 | |
| 52 | 57 | fn addMachOCases(cases: *tests.StandaloneContext) void { |
test/link/wasm/archive/build.zig created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 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 | // The code in question will pull-in compiler-rt, | |
| 11 | // and therefore link with its archive file. | |
| 12 | const lib = b.addSharedLibrary("main", "main.zig", .unversioned); | |
| 13 | lib.setBuildMode(mode); | |
| 14 | lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding }); | |
| 15 | lib.use_llvm = false; | |
| 16 | lib.use_stage1 = false; | |
| 17 | lib.use_lld = false; | |
| 18 | ||
| 19 | const check = lib.checkObject(.wasm); | |
| 20 | check.checkStart("Section import"); | |
| 21 | check.checkNext("entries 1"); // __truncsfhf2 should have been resolved, so only 1 import (compiler-rt's memcpy). | |
| 22 | ||
| 23 | check.checkStart("Section custom"); | |
| 24 | check.checkNext("name __truncsfhf2"); // Ensure it was imported and resolved | |
| 25 | ||
| 26 | test_step.dependOn(&check.step); | |
| 27 | } |
test/link/wasm/archive/main.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | export fn foo() void { | |
| 2 | var a: f16 = 2.2; | |
| 3 | // this will pull-in compiler-rt | |
| 4 | var b = @trunc(a); | |
| 5 | _ = b; | |
| 6 | } |