zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit d500caaa62aa666916f44dc07f2e618a2260f640 (tree)
parent b70fedee7e61d0243211ef36635681fcb998ca54
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Mon, 15 Jan 2024 11:46:32 +0100

test/link/macho: test stacksize option

Diffstat:
Mtest/link.zig | 4----
Mtest/link/macho.zig | 21++++++++++++++++++++-
Dtest/link/macho/stack_size/build.zig | 37-------------------------------------
Dtest/link/macho/stack_size/main.c | 3---
4 files changed, 20 insertions(+), 45 deletions(-)

diff --git a/test/link.zig b/test/link.zig @@ -120,10 +120,6 @@ pub const cases = [_]Case{ .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 @@ -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 @@ -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 @@ -1,3 +0,0 @@ -int main(int argc, char* argv[]) { - return 0; -}