authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-15 11:46:32+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
logd500caaa62aa666916f44dc07f2e618a2260f640
treeefaf71f8f0fd01fcea7c748422026b838d052319
parentb70fedee7e61d0243211ef36635681fcb998ca54

test/link/macho: test stacksize option


4 files changed, 20 insertions(+), 45 deletions(-)

test/link.zig-4
......@@ -119,10 +119,6 @@ pub const cases = [_]Case{
119119 .build_root = "test/link/macho/reexports",
120120 .import = @import("link/macho/reexports/build.zig"),
121121 },
122 .{
123 .build_root = "test/link/macho/stack_size",
124 .import = @import("link/macho/stack_size/build.zig"),
125 },
126122 .{
127123 .build_root = "test/link/macho/tbdv3",
128124 .import = @import("link/macho/tbdv3/build.zig"),
test/link/macho.zig+20-1
......@@ -33,6 +33,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
3333 macho_step.dependOn(testRelocatableZig(b, .{ .target = default_target }));
3434 macho_step.dependOn(testSectionBoundarySymbols(b, .{ .target = default_target }));
3535 macho_step.dependOn(testSegmentBoundarySymbols(b, .{ .target = default_target }));
36 macho_step.dependOn(testStackSize(b, .{ .target = default_target }));
3637 macho_step.dependOn(testTentative(b, .{ .target = default_target }));
3738 macho_step.dependOn(testThunks(b, .{ .target = aarch64_target }));
3839 macho_step.dependOn(testTlsLargeTbss(b, .{ .target = default_target }));
......@@ -45,7 +46,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
4546 macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target }));
4647 macho_step.dependOn(testDylib(b, .{ .target = default_target }));
4748 macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target }));
48 macho_step.dependOn(testSearchStrategy(b, .{ .target = b.host }));
49 macho_step.dependOn(testSearchStrategy(b, .{ .target = default_target }));
4950 macho_step.dependOn(testTls(b, .{ .target = default_target }));
5051 macho_step.dependOn(testTwoLevelNamespace(b, .{ .target = default_target }));
5152 macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target }));
......@@ -1263,6 +1264,24 @@ fn testSegmentBoundarySymbols(b: *Build, opts: Options) *Step {
12631264 return test_step;
12641265}
12651266
1267fn testStackSize(b: *Build, opts: Options) *Step {
1268 const test_step = addTestStep(b, "macho-stack-size", opts);
1269
1270 const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" });
1271 exe.stack_size = 0x100000000;
1272
1273 const run = addRunArtifact(exe);
1274 test_step.dependOn(&run.step);
1275
1276 const check = exe.checkObject();
1277 check.checkInHeaders();
1278 check.checkExact("cmd MAIN");
1279 check.checkExact("stacksize 100000000");
1280 test_step.dependOn(&check.step);
1281
1282 return test_step;
1283}
1284
12661285fn testTentative(b: *Build, opts: Options) *Step {
12671286 const test_step = addTestStep(b, "macho-tentative", opts);
12681287
test/link/macho/stack_size/build.zig deleted-37
......@@ -1,37 +0,0 @@
1const std = @import("std");
2
3pub const requires_symlinks = true;
4
5pub fn build(b: *std.Build) void {
6 const test_step = b.step("test", "Test it");
7 b.default_step = test_step;
8
9 add(b, test_step, .Debug);
10 add(b, test_step, .ReleaseFast);
11 add(b, test_step, .ReleaseSmall);
12 add(b, test_step, .ReleaseSafe);
13}
14
15fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void {
16 const target = b.resolveTargetQuery(.{ .os_tag = .macos });
17
18 const exe = b.addExecutable(.{
19 .name = "main",
20 .optimize = optimize,
21 .target = target,
22 });
23 exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &.{} });
24 exe.linkLibC();
25 exe.stack_size = 0x100000000;
26
27 const check_exe = exe.checkObject();
28 check_exe.checkInHeaders();
29 check_exe.checkExact("cmd MAIN");
30 check_exe.checkExact("stacksize 100000000");
31 test_step.dependOn(&check_exe.step);
32
33 const run = b.addRunArtifact(exe);
34 run.skip_foreign_checks = true;
35 run.expectStdOutEqual("");
36 test_step.dependOn(&run.step);
37}
test/link/macho/stack_size/main.c deleted-3
......@@ -1,3 +0,0 @@
1int main(int argc, char* argv[]) {
2 return 0;
3}