diff options
| author | Alex Rønne Petersen <alex@alexrp.com> | 2025-01-18 14:32:55 +0100 |
|---|---|---|
| committer | Alex Rønne Petersen <alex@alexrp.com> | 2025-01-19 02:15:30 +0100 |
| commit | 45bb4f955c8c8be40ed8b2247eaaa70661cf1b3d (patch) | |
| tree | e853b03b4f905f02908550d0cdf755ba353dbd29 /test | |
| parent | 8a78d875cc1cdab2648e7413fc0d2eea5afc6991 (diff) | |
| download | zig-45bb4f955c8c8be40ed8b2247eaaa70661cf1b3d.tar.gz zig-45bb4f955c8c8be40ed8b2247eaaa70661cf1b3d.zip | |
test: Add a standalone test for omitting CFI directives.
Diffstat (limited to 'test')
| -rw-r--r-- | test/standalone/build.zig.zon | 3 | ||||
| -rw-r--r-- | test/standalone/omit_cfi/build.zig | 67 | ||||
| -rw-r--r-- | test/standalone/omit_cfi/main.zig | 1 |
3 files changed, 71 insertions, 0 deletions
diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon index 06ebe980d1..9863e7cc6d 100644 --- a/test/standalone/build.zig.zon +++ b/test/standalone/build.zig.zon @@ -183,6 +183,9 @@ .empty_global_error_set = .{ .path = "empty_global_error_set", }, + .omit_cfi = .{ + .path = "omit_cfi", + }, }, .paths = .{ "build.zig", diff --git a/test/standalone/omit_cfi/build.zig b/test/standalone/omit_cfi/build.zig new file mode 100644 index 0000000000..62f9fed471 --- /dev/null +++ b/test/standalone/omit_cfi/build.zig @@ -0,0 +1,67 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + inline for (.{ + .aarch64, + .aarch64_be, + .hexagon, + .loongarch64, + .mips, + .mipsel, + .mips64, + .mips64el, + .powerpc, + .powerpcle, + .powerpc64, + .powerpc64le, + .riscv32, + .riscv64, + .s390x, + .sparc64, + .x86, + .x86_64, + }) |arch| { + const target = b.resolveTargetQuery(.{ + .cpu_arch = arch, + .os_tag = .linux, + }); + + const omit_dbg = b.addExecutable(.{ + .name = b.fmt("{s}-linux-omit-dbg", .{@tagName(arch)}), + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .target = target, + .optimize = .Debug, + // We are mainly concerned with CFI directives in our non-libc startup code and syscall + // code, so make it explicit that we don't want libc. + .link_libc = false, + .strip = true, + }), + }); + + const omit_uwt = b.addExecutable(.{ + .name = b.fmt("{s}-linux-omit-uwt", .{@tagName(arch)}), + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .target = target, + .optimize = .Debug, + .link_libc = false, + .unwind_tables = .none, + }), + }); + + const omit_both = b.addExecutable(.{ + .name = b.fmt("{s}-linux-omit-both", .{@tagName(arch)}), + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .target = target, + .optimize = .Debug, + .link_libc = false, + .strip = true, + .unwind_tables = .none, + }), + }); + + inline for (.{ omit_dbg, omit_uwt, omit_both }) |step| b.installArtifact(step); + } +} diff --git a/test/standalone/omit_cfi/main.zig b/test/standalone/omit_cfi/main.zig new file mode 100644 index 0000000000..902b554db0 --- /dev/null +++ b/test/standalone/omit_cfi/main.zig @@ -0,0 +1 @@ +pub fn main() void {} |
