Skip to content

Commit 45bb4f9

Browse files
committed
test: Add a standalone test for omitting CFI directives.
1 parent 8a78d87 commit 45bb4f9

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

test/standalone/build.zig.zon

+3
Original file line numberDiff line numberDiff line change
@@ -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

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const std = @import("std");
2+
3+
pub 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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn main() void {}

0 commit comments

Comments
 (0)