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 {
33 b.default_step = test_step;
44
55 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");
7 addOne(b, test_step, b.graph.host, false, .dynamic, false, "elf2-hello-native-selfhosted-dynamic");
8 addOne(b, test_step, b.graph.host, false, .static, true, "elf2-hello-native-selfhosted-static-pie");
9 addOne(b, test_step, b.graph.host, false, .dynamic, true, "elf2-hello-native-selfhosted-dynamic-pie");
10 addOne(b, test_step, b.graph.host, true, .static, false, "elf2-hello-native-llvm-static");
11 addOne(b, test_step, b.graph.host, true, .dynamic, false, "elf2-hello-native-llvm-dynamic");
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, false, "elf2-hello-native-selfhosted-dynamic");
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, false, "elf2-hello-native-selfhosted-dynamic-pie");
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, false, "elf2-hello-native-llvm-dynamic");
1212 }
1313
1414 const x86_64_linux_target: Build.ResolvedTarget = b.resolveTargetQuery(.{
1515 .cpu_arch = .x86_64,
1616 .os_tag = .linux,
1717 });
18 addOne(b, test_step, x86_64_linux_target, false, .static, false, "elf2-hello-selfhosted-static");
19 addOne(b, test_step, x86_64_linux_target, false, .static, true, "elf2-hello-selfhosted-static-pie");
20 addOne(b, test_step, x86_64_linux_target, true, .static, false, "elf2-hello-llvm-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, false, "elf2-hello-selfhosted-static-pie");
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");
2124}
2225
2326fn addOne(
......@@ -27,13 +30,14 @@ fn addOne(
2730 use_llvm: bool,
2831 link_mode: std.lang.LinkMode,
2932 pie: bool,
33 force_link_libc: bool,
3034 name: []const u8,
3135) void {
3236 const mod = b.createModule(.{
3337 .root_source_file = b.path("hello.zig"),
3438 .target = target,
3539 .optimize = .debug,
36 .link_libc = link_mode == .dynamic,
40 .link_libc = link_mode == .dynamic or force_link_libc,
3741 });
3842 const exe = b.addExecutable(.{
3943 .name = name,