authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-18 14:32:55+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-01-19 02:15:30+01:00
log45bb4f955c8c8be40ed8b2247eaaa70661cf1b3d
treee853b03b4f905f02908550d0cdf755ba353dbd29
parent8a78d875cc1cdab2648e7413fc0d2eea5afc6991
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

test: Add a standalone test for omitting CFI directives.


3 files changed, 71 insertions(+), 0 deletions(-)

test/standalone/build.zig.zon+3
......@@ -183,6 +183,9 @@
183183 .empty_global_error_set = .{
184184 .path = "empty_global_error_set",
185185 },
186 .omit_cfi = .{
187 .path = "omit_cfi",
188 },
186189 },
187190 .paths = .{
188191 "build.zig",
test/standalone/omit_cfi/build.zig created+67
......@@ -0,0 +1,67 @@
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 inline for (.{
5 .aarch64,
6 .aarch64_be,
7 .hexagon,
8 .loongarch64,
9 .mips,
10 .mipsel,
11 .mips64,
12 .mips64el,
13 .powerpc,
14 .powerpcle,
15 .powerpc64,
16 .powerpc64le,
17 .riscv32,
18 .riscv64,
19 .s390x,
20 .sparc64,
21 .x86,
22 .x86_64,
23 }) |arch| {
24 const target = b.resolveTargetQuery(.{
25 .cpu_arch = arch,
26 .os_tag = .linux,
27 });
28
29 const omit_dbg = b.addExecutable(.{
30 .name = b.fmt("{s}-linux-omit-dbg", .{@tagName(arch)}),
31 .root_module = b.createModule(.{
32 .root_source_file = b.path("main.zig"),
33 .target = target,
34 .optimize = .Debug,
35 // We are mainly concerned with CFI directives in our non-libc startup code and syscall
36 // code, so make it explicit that we don't want libc.
37 .link_libc = false,
38 .strip = true,
39 }),
40 });
41
42 const omit_uwt = b.addExecutable(.{
43 .name = b.fmt("{s}-linux-omit-uwt", .{@tagName(arch)}),
44 .root_module = b.createModule(.{
45 .root_source_file = b.path("main.zig"),
46 .target = target,
47 .optimize = .Debug,
48 .link_libc = false,
49 .unwind_tables = .none,
50 }),
51 });
52
53 const omit_both = b.addExecutable(.{
54 .name = b.fmt("{s}-linux-omit-both", .{@tagName(arch)}),
55 .root_module = b.createModule(.{
56 .root_source_file = b.path("main.zig"),
57 .target = target,
58 .optimize = .Debug,
59 .link_libc = false,
60 .strip = true,
61 .unwind_tables = .none,
62 }),
63 });
64
65 inline for (.{ omit_dbg, omit_uwt, omit_both }) |step| b.installArtifact(step);
66 }
67}
test/standalone/omit_cfi/main.zig created+1
......@@ -0,0 +1 @@
1pub fn main() void {}