test/link/macho: test stacksize option

This commit is contained in:
Jakub Konka 2024-01-15 11:46:32 +01:00
parent b70fedee7e
commit d500caaa62
4 changed files with 20 additions and 45 deletions

View File

@ -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"),

View File

@ -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);

View File

@ -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);
}

View File

@ -1,3 +0,0 @@
int main(int argc, char* argv[]) {
return 0;
}