authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-09-30 16:29:47-07:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-09-30 16:29:47-07:00
logf81b328fb960557adc2c49dbcfac1002b98b621a
tree2b0cad73ea76433d589d00a7ed93f55e65339afd
parent979fd66270e389ab6bca6e40ad816c2cb6661421
signature Commit is signed but in an unrecognized format.

tests: test some libc targets in Elf2

This ensures that we are testing `Elf2`, *and* that we are testing building musl libc, even in `-Dskip-non-native` tests.

1 files changed, 14 insertions(+), 10 deletions(-)

test/standalone/elf2/build.zig+14-10
...@@ -3,21 +3,24 @@ pub fn build(b: *Build) void {...@@ -3,21 +3,24 @@ pub fn build(b: *Build) void {
3 b.default_step = test_step;3 b.default_step = test_step;
44
5 if (b.graph.host.result.cpu.arch == .x86_64 and b.graph.host.result.os.tag == .linux) {5 if (b.graph.host.result.cpu.arch == .x86_64 and b.graph.host.result.os.tag == .linux) {
6 addOne(b, test_step, b.graph.host, false, .static, false, "elf2-hello-native-selfhosted-static");6 addOne(b, test_step, b.graph.host, false, .static, false, false, "elf2-hello-native-selfhosted-static");
7 addOne(b, test_step, b.graph.host, false, .dynamic, false, "elf2-hello-native-selfhosted-dynamic");7 addOne(b, test_step, b.graph.host, false, .dynamic, false, false, "elf2-hello-native-selfhosted-dynamic");
8 addOne(b, test_step, b.graph.host, false, .static, true, "elf2-hello-native-selfhosted-static-pie");8 addOne(b, test_step, b.graph.host, false, .static, true, false, "elf2-hello-native-selfhosted-static-pie");
9 addOne(b, test_step, b.graph.host, false, .dynamic, true, "elf2-hello-native-selfhosted-dynamic-pie");9 addOne(b, test_step, b.graph.host, false, .dynamic, true, false, "elf2-hello-native-selfhosted-dynamic-pie");
10 addOne(b, test_step, b.graph.host, true, .static, false, "elf2-hello-native-llvm-static");10 addOne(b, test_step, b.graph.host, true, .static, false, false, "elf2-hello-native-llvm-static");
11 addOne(b, test_step, b.graph.host, true, .dynamic, false, "elf2-hello-native-llvm-dynamic");11 addOne(b, test_step, b.graph.host, true, .dynamic, false, false, "elf2-hello-native-llvm-dynamic");
12 }12 }
1313
14 const x86_64_linux_target: Build.ResolvedTarget = b.resolveTargetQuery(.{14 const x86_64_linux_target: Build.ResolvedTarget = b.resolveTargetQuery(.{
15 .cpu_arch = .x86_64,15 .cpu_arch = .x86_64,
16 .os_tag = .linux,16 .os_tag = .linux,
17 });17 });
18 addOne(b, test_step, x86_64_linux_target, false, .static, false, "elf2-hello-selfhosted-static");18 addOne(b, test_step, x86_64_linux_target, false, .static, false, false, "elf2-hello-selfhosted-static");
19 addOne(b, test_step, x86_64_linux_target, false, .static, true, "elf2-hello-selfhosted-static-pie");19 addOne(b, test_step, x86_64_linux_target, false, .static, true, false, "elf2-hello-selfhosted-static-pie");
20 addOne(b, test_step, x86_64_linux_target, true, .static, false, "elf2-hello-llvm-static");20 addOne(b, test_step, x86_64_linux_target, true, .static, false, false, "elf2-hello-llvm-static");
21 addOne(b, test_step, x86_64_linux_target, false, .static, false, true, "elf2-hello-selfhosted-static-libc");
22 addOne(b, test_step, x86_64_linux_target, false, .static, true, true, "elf2-hello-selfhosted-static-libc-pie");
23 addOne(b, test_step, x86_64_linux_target, true, .static, false, true, "elf2-hello-llvm-static-libc");
21}24}
2225
23fn addOne(26fn addOne(
...@@ -27,13 +30,14 @@ fn addOne(...@@ -27,13 +30,14 @@ fn addOne(
27 use_llvm: bool,30 use_llvm: bool,
28 link_mode: std.lang.LinkMode,31 link_mode: std.lang.LinkMode,
29 pie: bool,32 pie: bool,
33 force_link_libc: bool,
30 name: []const u8,34 name: []const u8,
31) void {35) void {
32 const mod = b.createModule(.{36 const mod = b.createModule(.{
33 .root_source_file = b.path("hello.zig"),37 .root_source_file = b.path("hello.zig"),
34 .target = target,38 .target = target,
35 .optimize = .debug,39 .optimize = .debug,
36 .link_libc = link_mode == .dynamic,40 .link_libc = link_mode == .dynamic or force_link_libc,
37 });41 });
38 const exe = b.addExecutable(.{42 const exe = b.addExecutable(.{
39 .name = name,43 .name = name,