From d500caaa62aa666916f44dc07f2e618a2260f640 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Mon, 15 Jan 2024 11:46:32 +0100 Subject: [PATCH] test/link/macho: test stacksize option --- test/link.zig | 4 --- test/link/macho.zig | 21 +++++++++++++++- test/link/macho/stack_size/build.zig | 37 ---------------------------- test/link/macho/stack_size/main.c | 3 --- 4 files changed, 20 insertions(+), 45 deletions(-) delete mode 100644 test/link/macho/stack_size/build.zig delete mode 100644 test/link/macho/stack_size/main.c diff --git a/test/link.zig b/test/link.zig index 9559d66a8..0eb39c2a5 100644 --- a/test/link.zig +++ b/test/link.zig @@ -119,10 +119,6 @@ pub const cases = [_]Case{ .build_root = "test/link/macho/reexports", .import = @import("link/macho/reexports/build.zig"), }, - .{ - .build_root = "test/link/macho/stack_size", - .import = @import("link/macho/stack_size/build.zig"), - }, .{ .build_root = "test/link/macho/tbdv3", .import = @import("link/macho/tbdv3/build.zig"), diff --git a/test/link/macho.zig b/test/link/macho.zig index 5a5b447bb..0cf2de1b8 100644 --- a/test/link/macho.zig +++ b/test/link/macho.zig @@ -33,6 +33,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target })); macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target })); macho_step.dependOn(testSegmentBoundarySymbols(b, .{ .target = default_target })); + macho_step.dependOn(testStackSize(b, .{ .target = default_target })); macho_step.dependOn(testTentative(b, .{ .target = default_target })); macho_step.dependOn(testThunks(b, .{ .target = aarch64_target })); macho_step.dependOn(testTlsLargeTbss(b, .{ .target = default_target })); @@ -45,7 +46,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target })); macho_step.dependOn(testDylib(b, .{ .target = default_target })); macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); - macho_step.dependOn(testSearchStrategy(b, .{ .target = b.host })); + macho_step.dependOn(testSearchStrategy(b, .{ .target = default_target })); macho_step.dependOn(testTls(b, .{ .target = default_target })); macho_step.dependOn(testTwoLevelNamespace(b, .{ .target = default_target })); macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); @@ -1263,6 +1264,24 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step { return test_step; } +fn testStackSize(b: *Build, opts: Options) *Step { + const test_step = addTestStep(b, "macho-stack-size", opts); + + const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" }); + exe.stack_size = 0x100000000; + + const run = addRunArtifact(exe); + test_step.dependOn(&run.step); + + const check = exe.checkObject(); + check.checkInHeaders(); + check.checkExact("cmd MAIN"); + check.checkExact("stacksize 100000000"); + test_step.dependOn(&check.step); + + return test_step; +} + fn testTentative(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "macho-tentative", opts); diff --git a/test/link/macho/stack_size/build.zig b/test/link/macho/stack_size/build.zig deleted file mode 100644 index 28a2602ea..000000000 --- a/test/link/macho/stack_size/build.zig +++ /dev/null @@ -1,37 +0,0 @@ -const std = @import("std"); - -pub const requires_symlinks = true; - -pub fn build(b: *std.Build) void { - const test_step = b.step("test", "Test it"); - b.default_step = test_step; - - add(b, test_step, .Debug); - add(b, test_step, .ReleaseFast); - add(b, test_step, .ReleaseSmall); - add(b, test_step, .ReleaseSafe); -} - -fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { - const target = b.resolveTargetQuery(.{ .os_tag = .macos }); - - const exe = b.addExecutable(.{ - .name = "main", - .optimize = optimize, - .target = target, - }); - exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} }); - exe.linkLibC(); - exe.stack_size = 0x100000000; - - const check_exe = exe.checkObject(); - check_exe.checkInHeaders(); - check_exe.checkExact("cmd MAIN"); - check_exe.checkExact("stacksize 100000000"); - test_step.dependOn(&check_exe.step); - - const run = b.addRunArtifact(exe); - run.skip_foreign_checks = true; - run.expectStdOutEqual(""); - test_step.dependOn(&run.step); -} diff --git a/test/link/macho/stack_size/main.c b/test/link/macho/stack_size/main.c deleted file mode 100644 index ca68d24cc..000000000 --- a/test/link/macho/stack_size/main.c +++ /dev/null @@ -1,3 +0,0 @@ -int main(int argc, char* argv[]) { - return 0; -}