From f81b328fb960557adc2c49dbcfac1002b98b621a Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Wed, 30 Sep 2026 16:29:47 -0700 Subject: [PATCH] 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. --- test/standalone/elf2/build.zig | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/test/standalone/elf2/build.zig b/test/standalone/elf2/build.zig index b8a656ec6d5172506a4866958072b48f92f27865..6bc29c26e382fb8e52b66fb04969b280fb670e0b 100644 --- a/test/standalone/elf2/build.zig +++ b/test/standalone/elf2/build.zig @@ -3,21 +3,24 @@ pub fn build(b: *Build) void { b.default_step = test_step; if (b.graph.host.result.cpu.arch == .x86_64 and b.graph.host.result.os.tag == .linux) { - addOne(b, test_step, b.graph.host, false, .static, false, "elf2-hello-native-selfhosted-static"); - addOne(b, test_step, b.graph.host, false, .dynamic, false, "elf2-hello-native-selfhosted-dynamic"); - addOne(b, test_step, b.graph.host, false, .static, true, "elf2-hello-native-selfhosted-static-pie"); - addOne(b, test_step, b.graph.host, false, .dynamic, true, "elf2-hello-native-selfhosted-dynamic-pie"); - addOne(b, test_step, b.graph.host, true, .static, false, "elf2-hello-native-llvm-static"); - addOne(b, test_step, b.graph.host, true, .dynamic, false, "elf2-hello-native-llvm-dynamic"); + addOne(b, test_step, b.graph.host, false, .static, false, false, "elf2-hello-native-selfhosted-static"); + addOne(b, test_step, b.graph.host, false, .dynamic, false, false, "elf2-hello-native-selfhosted-dynamic"); + addOne(b, test_step, b.graph.host, false, .static, true, false, "elf2-hello-native-selfhosted-static-pie"); + addOne(b, test_step, b.graph.host, false, .dynamic, true, false, "elf2-hello-native-selfhosted-dynamic-pie"); + addOne(b, test_step, b.graph.host, true, .static, false, false, "elf2-hello-native-llvm-static"); + addOne(b, test_step, b.graph.host, true, .dynamic, false, false, "elf2-hello-native-llvm-dynamic"); } const x86_64_linux_target: Build.ResolvedTarget = b.resolveTargetQuery(.{ .cpu_arch = .x86_64, .os_tag = .linux, }); - addOne(b, test_step, x86_64_linux_target, false, .static, false, "elf2-hello-selfhosted-static"); - addOne(b, test_step, x86_64_linux_target, false, .static, true, "elf2-hello-selfhosted-static-pie"); - addOne(b, test_step, x86_64_linux_target, true, .static, false, "elf2-hello-llvm-static"); + addOne(b, test_step, x86_64_linux_target, false, .static, false, false, "elf2-hello-selfhosted-static"); + addOne(b, test_step, x86_64_linux_target, false, .static, true, false, "elf2-hello-selfhosted-static-pie"); + addOne(b, test_step, x86_64_linux_target, true, .static, false, false, "elf2-hello-llvm-static"); + addOne(b, test_step, x86_64_linux_target, false, .static, false, true, "elf2-hello-selfhosted-static-libc"); + addOne(b, test_step, x86_64_linux_target, false, .static, true, true, "elf2-hello-selfhosted-static-libc-pie"); + addOne(b, test_step, x86_64_linux_target, true, .static, false, true, "elf2-hello-llvm-static-libc"); } fn addOne( @@ -27,13 +30,14 @@ fn addOne( use_llvm: bool, link_mode: std.lang.LinkMode, pie: bool, + force_link_libc: bool, name: []const u8, ) void { const mod = b.createModule(.{ .root_source_file = b.path("hello.zig"), .target = target, .optimize = .debug, - .link_libc = link_mode == .dynamic, + .link_libc = link_mode == .dynamic or force_link_libc, }); const exe = b.addExecutable(.{ .name = name, -- 2.54.0