| author | |
| committer | |
| log | 1142e0534351a57b81bd4a127f29745c62cc59c9 |
| tree | 6ad6df8fef7c05de06fe2a34fc577f7756a32652 |
| parent | 9a9b0083009f62dda9500f978544380a17b1f325 |
25 files changed, 385 insertions(+), 233 deletions(-)
build.zig+1-1| ... | @@ -454,7 +454,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -454,7 +454,7 @@ pub fn build(b: *std.Build) !void { |
| 454 | // enable_symlinks_windows, | 454 | // enable_symlinks_windows, |
| 455 | //)); | 455 | //)); |
| 456 | test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release)); | 456 | test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release)); |
| 457 | test_step.dependOn(tests.addLinkTests(b, test_filter, optimization_modes, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows)); | 457 | test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, skip_stage2_tests, enable_symlinks_windows)); |
| 458 | test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes)); | 458 | test_step.dependOn(tests.addStackTraceTests(b, test_filter, optimization_modes)); |
| 459 | test_step.dependOn(tests.addCliTests(b, test_filter, optimization_modes)); | 459 | test_step.dependOn(tests.addCliTests(b, test_filter, optimization_modes)); |
| 460 | test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes)); | 460 | test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filter, optimization_modes)); |
test/link.zig+97-116| ... | @@ -76,122 +76,103 @@ pub const cases = [_]Case{ | ... | @@ -76,122 +76,103 @@ pub const cases = [_]Case{ |
| 76 | }, | 76 | }, |
| 77 | 77 | ||
| 78 | // Mach-O Cases | 78 | // Mach-O Cases |
| 79 | // cases.addBuildFile("test/link/macho/bugs/13056/build.zig", .{ | 79 | .{ |
| 80 | // .build_modes = true, | 80 | .build_root = "test/link/macho/bugs/13056", |
| 81 | // .requires_macos_sdk = true, | 81 | .import = @import("link/macho/bugs/13056/build.zig"), |
| 82 | // .requires_symlinks = true, | 82 | }, |
| 83 | // }); | 83 | .{ |
| 84 | // | 84 | .build_root = "test/link/macho/bugs/13457", |
| 85 | // cases.addBuildFile("test/link/macho/bugs/13457/build.zig", .{ | 85 | .import = @import("link/macho/bugs/13457/build.zig"), |
| 86 | // .build_modes = true, | 86 | }, |
| 87 | // .requires_symlinks = true, | 87 | .{ |
| 88 | // }); | 88 | .build_root = "test/link/macho/bugs/13457", |
| 89 | // | 89 | .import = @import("link/macho/bugs/13457/build.zig"), |
| 90 | // cases.addBuildFile("test/link/macho/dead_strip/build.zig", .{ | 90 | }, |
| 91 | // .build_modes = false, | 91 | .{ |
| 92 | // .requires_symlinks = true, | 92 | .build_root = "test/link/macho/dead_strip", |
| 93 | // }); | 93 | .import = @import("link/macho/dead_strip/build.zig"), |
| 94 | // | 94 | }, |
| 95 | // cases.addBuildFile("test/link/macho/dead_strip_dylibs/build.zig", .{ | 95 | .{ |
| 96 | // .build_modes = true, | 96 | .build_root = "test/link/macho/dead_strip_dylibs", |
| 97 | // .requires_macos_sdk = true, | 97 | .import = @import("link/macho/dead_strip_dylibs/build.zig"), |
| 98 | // .requires_symlinks = true, | 98 | }, |
| 99 | // }); | 99 | .{ |
| 100 | // | 100 | .build_root = "test/link/macho/dylib", |
| 101 | // cases.addBuildFile("test/link/macho/dylib/build.zig", .{ | 101 | .import = @import("link/macho/dylib/build.zig"), |
| 102 | // .build_modes = true, | 102 | }, |
| 103 | // .requires_symlinks = true, | 103 | .{ |
| 104 | // }); | 104 | .build_root = "test/link/macho/empty", |
| 105 | // | 105 | .import = @import("link/macho/empty/build.zig"), |
| 106 | // cases.addBuildFile("test/link/macho/empty/build.zig", .{ | 106 | }, |
| 107 | // .build_modes = true, | 107 | .{ |
| 108 | // .requires_symlinks = true, | 108 | .build_root = "test/link/macho/entry", |
| 109 | // }); | 109 | .import = @import("link/macho/entry/build.zig"), |
| 110 | // | 110 | }, |
| 111 | // cases.addBuildFile("test/link/macho/entry/build.zig", .{ | 111 | .{ |
| 112 | // .build_modes = true, | 112 | .build_root = "test/link/macho/headerpad", |
| 113 | // .requires_symlinks = true, | 113 | .import = @import("link/macho/headerpad/build.zig"), |
| 114 | // }); | 114 | }, |
| 115 | // | 115 | .{ |
| 116 | // cases.addBuildFile("test/link/macho/headerpad/build.zig", .{ | 116 | .build_root = "test/link/macho/linksection", |
| 117 | // .build_modes = true, | 117 | .import = @import("link/macho/linksection/build.zig"), |
| 118 | // .requires_macos_sdk = true, | 118 | }, |
| 119 | // .requires_symlinks = true, | 119 | .{ |
| 120 | // }); | 120 | .build_root = "test/link/macho/needed_framework", |
| 121 | // | 121 | .import = @import("link/macho/needed_framework/build.zig"), |
| 122 | // cases.addBuildFile("test/link/macho/linksection/build.zig", .{ | 122 | }, |
| 123 | // .build_modes = true, | 123 | .{ |
| 124 | // .requires_symlinks = true, | 124 | .build_root = "test/link/macho/needed_library", |
| 125 | // }); | 125 | .import = @import("link/macho/needed_library/build.zig"), |
| 126 | // | 126 | }, |
| 127 | // cases.addBuildFile("test/link/macho/needed_framework/build.zig", .{ | 127 | .{ |
| 128 | // .build_modes = true, | 128 | .build_root = "test/link/macho/objc", |
| 129 | // .requires_macos_sdk = true, | 129 | .import = @import("link/macho/objc/build.zig"), |
| 130 | // .requires_symlinks = true, | 130 | }, |
| 131 | // }); | 131 | .{ |
| 132 | // | 132 | .build_root = "test/link/macho/objcpp", |
| 133 | // cases.addBuildFile("test/link/macho/needed_library/build.zig", .{ | 133 | .import = @import("link/macho/objcpp/build.zig"), |
| 134 | // .build_modes = true, | 134 | }, |
| 135 | // .requires_symlinks = true, | 135 | .{ |
| 136 | // }); | 136 | .build_root = "test/link/macho/pagezero", |
| 137 | // | 137 | .import = @import("link/macho/pagezero/build.zig"), |
| 138 | // cases.addBuildFile("test/link/macho/objc/build.zig", .{ | 138 | }, |
| 139 | // .build_modes = true, | 139 | .{ |
| 140 | // .requires_macos_sdk = true, | 140 | .build_root = "test/link/macho/search_strategy", |
| 141 | // .requires_symlinks = true, | 141 | .import = @import("link/macho/search_strategy/build.zig"), |
| 142 | // }); | 142 | }, |
| 143 | // | 143 | .{ |
| 144 | // cases.addBuildFile("test/link/macho/objcpp/build.zig", .{ | 144 | .build_root = "test/link/macho/stack_size", |
| 145 | // .build_modes = true, | 145 | .import = @import("link/macho/stack_size/build.zig"), |
| 146 | // .requires_macos_sdk = true, | 146 | }, |
| 147 | // .requires_symlinks = true, | 147 | .{ |
| 148 | // }); | 148 | .build_root = "test/link/macho/strict_validation", |
| 149 | // | 149 | .import = @import("link/macho/strict_validation/build.zig"), |
| 150 | // cases.addBuildFile("test/link/macho/pagezero/build.zig", .{ | 150 | }, |
| 151 | // .build_modes = false, | 151 | .{ |
| 152 | // .requires_symlinks = true, | 152 | .build_root = "test/link/macho/tls", |
| 153 | // }); | 153 | .import = @import("link/macho/tls/build.zig"), |
| 154 | // | 154 | }, |
| 155 | // cases.addBuildFile("test/link/macho/search_strategy/build.zig", .{ | 155 | .{ |
| 156 | // .build_modes = true, | 156 | .build_root = "test/link/macho/unwind_info", |
| 157 | // .requires_symlinks = true, | 157 | .import = @import("link/macho/unwind_info/build.zig"), |
| 158 | // }); | 158 | }, |
| 159 | // | 159 | // TODO: re-enable this test. It currently has some incompatibilities with |
| 160 | // cases.addBuildFile("test/link/macho/stack_size/build.zig", .{ | 160 | // the new build system API. In particular, it depends on installing the build |
| 161 | // .build_modes = true, | 161 | // artifacts, which should be unnecessary, and it has a custom build step that |
| 162 | // .requires_symlinks = true, | 162 | // prints directly to stderr instead of failing the step with an error message. |
| 163 | // }); | 163 | //.{ |
| 164 | // | 164 | // .build_root = "test/link/macho/uuid", |
| 165 | // cases.addBuildFile("test/link/macho/strict_validation/build.zig", .{ | 165 | // .import = @import("link/macho/uuid/build.zig"), |
| 166 | // .build_modes = true, | 166 | //}, |
| 167 | // .requires_symlinks = true, | 167 | |
| 168 | // }); | 168 | .{ |
| 169 | // | 169 | .build_root = "test/link/macho/weak_library", |
| 170 | // cases.addBuildFile("test/link/macho/tls/build.zig", .{ | 170 | .import = @import("link/macho/weak_library/build.zig"), |
| 171 | // .build_modes = true, | 171 | }, |
| 172 | // .requires_symlinks = true, | 172 | .{ |
| 173 | // }); | 173 | .build_root = "test/link/macho/weak_framework", |
| 174 | // | 174 | .import = @import("link/macho/weak_framework/build.zig"), |
| 175 | // cases.addBuildFile("test/link/macho/unwind_info/build.zig", .{ | 175 | }, |
| 176 | // .build_modes = true, | ||
| 177 | // .requires_symlinks = true, | ||
| 178 | // }); | ||
| 179 | // | ||
| 180 | // cases.addBuildFile("test/link/macho/uuid/build.zig", .{ | ||
| 181 | // .build_modes = false, | ||
| 182 | // .requires_symlinks = true, | ||
| 183 | // }); | ||
| 184 | // | ||
| 185 | // cases.addBuildFile("test/link/macho/weak_library/build.zig", .{ | ||
| 186 | // .build_modes = true, | ||
| 187 | // .requires_symlinks = true, | ||
| 188 | // }); | ||
| 189 | // | ||
| 190 | // cases.addBuildFile("test/link/macho/weak_framework/build.zig", .{ | ||
| 191 | // .build_modes = true, | ||
| 192 | // .requires_macos_sdk = true, | ||
| 193 | // .requires_symlinks = true, | ||
| 194 | // }); | ||
| 195 | }; | 176 | }; |
| 196 | 177 | ||
| 197 | const std = @import("std"); | 178 | const std = @import("std"); |
test/link/macho/bugs/13056/build.zig+12-4| ... | @@ -1,20 +1,28 @@ | ... | @@ -1,20 +1,28 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_macos_sdk = true; | ||
| 4 | pub const requires_symlinks = true; | ||
| 5 | |||
| 3 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 8 | b.default_step = test_step; | ||
| 9 | |||
| 10 | add(b, test_step, .Debug); | ||
| 11 | add(b, test_step, .ReleaseFast); | ||
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 5 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 6 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 17 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; |
| 7 | const target_info = std.zig.system.NativeTargetInfo.detect(target) catch unreachable; | 18 | const target_info = std.zig.system.NativeTargetInfo.detect(target) catch unreachable; |
| 8 | const sdk = std.zig.system.darwin.getDarwinSDK(b.allocator, target_info.target) orelse | 19 | const sdk = std.zig.system.darwin.getDarwinSDK(b.allocator, target_info.target) orelse |
| 9 | @panic("macOS SDK is required to run the test"); | 20 | @panic("macOS SDK is required to run the test"); |
| 10 | 21 | ||
| 11 | const test_step = b.step("test", "Test the program"); | ||
| 12 | |||
| 13 | const exe = b.addExecutable(.{ | 22 | const exe = b.addExecutable(.{ |
| 14 | .name = "test", | 23 | .name = "test", |
| 15 | .optimize = optimize, | 24 | .optimize = optimize, |
| 16 | }); | 25 | }); |
| 17 | b.default_step.dependOn(&exe.step); | ||
| 18 | exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include" }) catch unreachable); | 26 | exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include" }) catch unreachable); |
| 19 | exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include/c++/v1" }) catch unreachable); | 27 | exe.addIncludePath(std.fs.path.join(b.allocator, &.{ sdk.path, "/usr/include/c++/v1" }) catch unreachable); |
| 20 | exe.addCSourceFile("test.cpp", &.{ | 28 | exe.addCSourceFile("test.cpp", &.{ |
test/link/macho/bugs/13457/build.zig+13-3| ... | @@ -1,10 +1,19 @@ | ... | @@ -1,10 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 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 | } | ||
| 6 | 14 | ||
| 7 | const test_step = b.step("test", "Test the program"); | 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { |
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 8 | 17 | ||
| 9 | const exe = b.addExecutable(.{ | 18 | const exe = b.addExecutable(.{ |
| 10 | .name = "test", | 19 | .name = "test", |
| ... | @@ -16,5 +25,6 @@ pub fn build(b: *std.Build) void { | ... | @@ -16,5 +25,6 @@ pub fn build(b: *std.Build) void { |
| 16 | const run = b.addRunArtifact(exe); | 25 | const run = b.addRunArtifact(exe); |
| 17 | run.skip_foreign_checks = true; | 26 | run.skip_foreign_checks = true; |
| 18 | run.expectStdOutEqual(""); | 27 | run.expectStdOutEqual(""); |
| 28 | |||
| 19 | test_step.dependOn(&run.step); | 29 | test_step.dependOn(&run.step); |
| 20 | } | 30 | } |
test/link/macho/dead_strip/build.zig+8-5| ... | @@ -1,15 +1,17 @@ | ... | @@ -1,15 +1,17 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test the program"); | 9 | const test_step = b.step("test", "Test the program"); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | b.default_step = test_step; |
| 9 | 11 | ||
| 10 | { | 12 | { |
| 11 | // Without -dead_strip, we expect `iAmUnused` symbol present | 13 | // Without -dead_strip, we expect `iAmUnused` symbol present |
| 12 | const exe = createScenario(b, optimize, target); | 14 | const exe = createScenario(b, optimize, target, "no-gc"); |
| 13 | 15 | ||
| 14 | const check = exe.checkObject(.macho); | 16 | const check = exe.checkObject(.macho); |
| 15 | check.checkInSymtab(); | 17 | check.checkInSymtab(); |
| ... | @@ -22,7 +24,7 @@ pub fn build(b: *std.Build) void { | ... | @@ -22,7 +24,7 @@ pub fn build(b: *std.Build) void { |
| 22 | 24 | ||
| 23 | { | 25 | { |
| 24 | // With -dead_strip, no `iAmUnused` symbol should be present | 26 | // With -dead_strip, no `iAmUnused` symbol should be present |
| 25 | const exe = createScenario(b, optimize, target); | 27 | const exe = createScenario(b, optimize, target, "yes-gc"); |
| 26 | exe.link_gc_sections = true; | 28 | exe.link_gc_sections = true; |
| 27 | 29 | ||
| 28 | const check = exe.checkObject(.macho); | 30 | const check = exe.checkObject(.macho); |
| ... | @@ -39,9 +41,10 @@ fn createScenario( | ... | @@ -39,9 +41,10 @@ fn createScenario( |
| 39 | b: *std.Build, | 41 | b: *std.Build, |
| 40 | optimize: std.builtin.OptimizeMode, | 42 | optimize: std.builtin.OptimizeMode, |
| 41 | target: std.zig.CrossTarget, | 43 | target: std.zig.CrossTarget, |
| 44 | name: []const u8, | ||
| 42 | ) *std.Build.CompileStep { | 45 | ) *std.Build.CompileStep { |
| 43 | const exe = b.addExecutable(.{ | 46 | const exe = b.addExecutable(.{ |
| 44 | .name = "test", | 47 | .name = name, |
| 45 | .optimize = optimize, | 48 | .optimize = optimize, |
| 46 | .target = target, | 49 | .target = target, |
| 47 | }); | 50 | }); |
test/link/macho/dead_strip_dylibs/build.zig+21-9| ... | @@ -1,14 +1,22 @@ | ... | @@ -1,14 +1,22 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_macos_sdk = true; | ||
| 4 | pub const requires_symlinks = true; | ||
| 5 | |||
| 3 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 8 | b.default_step = test_step; | ||
| 5 | 9 | ||
| 6 | const test_step = b.step("test", "Test the program"); | 10 | add(b, test_step, .Debug); |
| 7 | test_step.dependOn(b.getInstallStep()); | 11 | add(b, test_step, .ReleaseFast); |
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 8 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 9 | { | 17 | { |
| 10 | // Without -dead_strip_dylibs we expect `-la` to include liba.dylib in the final executable | 18 | // Without -dead_strip_dylibs we expect `-la` to include liba.dylib in the final executable |
| 11 | const exe = createScenario(b, optimize); | 19 | const exe = createScenario(b, optimize, "no-dead-strip"); |
| 12 | 20 | ||
| 13 | const check = exe.checkObject(.macho); | 21 | const check = exe.checkObject(.macho); |
| 14 | check.checkStart("cmd LOAD_DYLIB"); | 22 | check.checkStart("cmd LOAD_DYLIB"); |
| ... | @@ -25,18 +33,22 @@ pub fn build(b: *std.Build) void { | ... | @@ -25,18 +33,22 @@ pub fn build(b: *std.Build) void { |
| 25 | 33 | ||
| 26 | { | 34 | { |
| 27 | // With -dead_strip_dylibs, we should include liba.dylib as it's unreachable | 35 | // With -dead_strip_dylibs, we should include liba.dylib as it's unreachable |
| 28 | const exe = createScenario(b, optimize); | 36 | const exe = createScenario(b, optimize, "yes-dead-strip"); |
| 29 | exe.dead_strip_dylibs = true; | 37 | exe.dead_strip_dylibs = true; |
| 30 | 38 | ||
| 31 | const run_cmd = exe.run(); | 39 | const run_cmd = b.addRunArtifact(exe); |
| 32 | run_cmd.expected_term = .{ .Exited = @bitCast(u8, @as(i8, -2)) }; // should fail | 40 | run_cmd.expectExitCode(@bitCast(u8, @as(i8, -2))); // should fail |
| 33 | test_step.dependOn(&run_cmd.step); | 41 | test_step.dependOn(&run_cmd.step); |
| 34 | } | 42 | } |
| 35 | } | 43 | } |
| 36 | 44 | ||
| 37 | fn createScenario(b: *std.Build, optimize: std.builtin.OptimizeMode) *std.Build.CompileStep { | 45 | fn createScenario( |
| 46 | b: *std.Build, | ||
| 47 | optimize: std.builtin.OptimizeMode, | ||
| 48 | name: []const u8, | ||
| 49 | ) *std.Build.CompileStep { | ||
| 38 | const exe = b.addExecutable(.{ | 50 | const exe = b.addExecutable(.{ |
| 39 | .name = "test", | 51 | .name = name, |
| 40 | .optimize = optimize, | 52 | .optimize = optimize, |
| 41 | }); | 53 | }); |
| 42 | exe.addCSourceFile("main.c", &[0][]const u8{}); | 54 | exe.addCSourceFile("main.c", &[0][]const u8{}); |
test/link/macho/dylib/build.zig+18-9| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | const dylib = b.addSharedLibrary(.{ | 18 | const dylib = b.addSharedLibrary(.{ |
| 11 | .name = "a", | 19 | .name = "a", |
| ... | @@ -15,7 +23,6 @@ pub fn build(b: *std.Build) void { | ... | @@ -15,7 +23,6 @@ pub fn build(b: *std.Build) void { |
| 15 | }); | 23 | }); |
| 16 | dylib.addCSourceFile("a.c", &.{}); | 24 | dylib.addCSourceFile("a.c", &.{}); |
| 17 | dylib.linkLibC(); | 25 | dylib.linkLibC(); |
| 18 | dylib.install(); | ||
| 19 | 26 | ||
| 20 | const check_dylib = dylib.checkObject(.macho); | 27 | const check_dylib = dylib.checkObject(.macho); |
| 21 | check_dylib.checkStart("cmd ID_DYLIB"); | 28 | check_dylib.checkStart("cmd ID_DYLIB"); |
| ... | @@ -33,9 +40,9 @@ pub fn build(b: *std.Build) void { | ... | @@ -33,9 +40,9 @@ pub fn build(b: *std.Build) void { |
| 33 | }); | 40 | }); |
| 34 | exe.addCSourceFile("main.c", &.{}); | 41 | exe.addCSourceFile("main.c", &.{}); |
| 35 | exe.linkSystemLibrary("a"); | 42 | exe.linkSystemLibrary("a"); |
| 43 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); | ||
| 44 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); | ||
| 36 | exe.linkLibC(); | 45 | exe.linkLibC(); |
| 37 | exe.addLibraryPath(b.pathFromRoot("zig-out/lib/")); | ||
| 38 | exe.addRPath(b.pathFromRoot("zig-out/lib")); | ||
| 39 | 46 | ||
| 40 | const check_exe = exe.checkObject(.macho); | 47 | const check_exe = exe.checkObject(.macho); |
| 41 | check_exe.checkStart("cmd LOAD_DYLIB"); | 48 | check_exe.checkStart("cmd LOAD_DYLIB"); |
| ... | @@ -45,10 +52,12 @@ pub fn build(b: *std.Build) void { | ... | @@ -45,10 +52,12 @@ pub fn build(b: *std.Build) void { |
| 45 | check_exe.checkNext("compatibility version 10000"); | 52 | check_exe.checkNext("compatibility version 10000"); |
| 46 | 53 | ||
| 47 | check_exe.checkStart("cmd RPATH"); | 54 | check_exe.checkStart("cmd RPATH"); |
| 48 | check_exe.checkNext(std.fmt.allocPrint(b.allocator, "path {s}", .{b.pathFromRoot("zig-out/lib")}) catch unreachable); | 55 | // TODO check this (perhaps with `checkNextFileSource(dylib.getOutputDirectorySource())`) |
| 56 | //check_exe.checkNext(std.fmt.allocPrint(b.allocator, "path {s}", .{ | ||
| 57 | // b.pathFromRoot("zig-out/lib"), | ||
| 58 | //}) catch unreachable); | ||
| 49 | 59 | ||
| 50 | const run = check_exe.runAndCompare(); | 60 | const run = check_exe.runAndCompare(); |
| 51 | run.cwd = b.pathFromRoot("."); | ||
| 52 | run.expectStdOutEqual("Hello world"); | 61 | run.expectStdOutEqual("Hello world"); |
| 53 | test_step.dependOn(&run.step); | 62 | test_step.dependOn(&run.step); |
| 54 | } | 63 | } |
test/link/macho/empty/build.zig+12-4| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test the program"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | const exe = b.addExecutable(.{ | 18 | const exe = b.addExecutable(.{ |
| 11 | .name = "test", | 19 | .name = "test", |
test/link/macho/entry/build.zig+10-3| ... | @@ -1,11 +1,18 @@ | ... | @@ -1,11 +1,18 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 7 | b.default_step = test_step; | ||
| 5 | 8 | ||
| 6 | const test_step = b.step("test", "Test"); | 9 | add(b, test_step, .Debug); |
| 7 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 8 | 14 | ||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 9 | const exe = b.addExecutable(.{ | 16 | const exe = b.addExecutable(.{ |
| 10 | .name = "main", | 17 | .name = "main", |
| 11 | .optimize = optimize, | 18 | .optimize = optimize, |
test/link/macho/headerpad/build.zig+11-3| ... | @@ -1,12 +1,20 @@ | ... | @@ -1,12 +1,20 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub const requires_symlinks = true; | ||
| 5 | pub const requires_macos_sdk = true; | ||
| 6 | |||
| 4 | pub fn build(b: *std.Build) void { | 7 | pub fn build(b: *std.Build) void { |
| 5 | const optimize = b.standardOptimizeOption(.{}); | 8 | const test_step = b.step("test", "Test it"); |
| 9 | b.default_step = test_step; | ||
| 6 | 10 | ||
| 7 | const test_step = b.step("test", "Test"); | 11 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 12 | add(b, test_step, .ReleaseFast); |
| 13 | add(b, test_step, .ReleaseSmall); | ||
| 14 | add(b, test_step, .ReleaseSafe); | ||
| 15 | } | ||
| 9 | 16 | ||
| 17 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 10 | { | 18 | { |
| 11 | // Test -headerpad_max_install_names | 19 | // Test -headerpad_max_install_names |
| 12 | const exe = simpleExe(b, optimize); | 20 | const exe = simpleExe(b, optimize); |
test/link/macho/linksection/build.zig+12-4| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target = std.zig.CrossTarget{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target = std.zig.CrossTarget{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | const obj = b.addObject(.{ | 18 | const obj = b.addObject(.{ |
| 11 | .name = "test", | 19 | .name = "test", |
test/link/macho/needed_framework/build.zig+11-3| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | pub const requires_macos_sdk = true; | ||
| 5 | |||
| 3 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 8 | b.default_step = test_step; | ||
| 5 | 9 | ||
| 6 | const test_step = b.step("test", "Test the program"); | 10 | add(b, test_step, .Debug); |
| 7 | test_step.dependOn(b.getInstallStep()); | 11 | add(b, test_step, .ReleaseFast); |
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 8 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 9 | // -dead_strip_dylibs | 17 | // -dead_strip_dylibs |
| 10 | // -needed_framework Cocoa | 18 | // -needed_framework Cocoa |
| 11 | const exe = b.addExecutable(.{ | 19 | const exe = b.addExecutable(.{ |
test/link/macho/needed_library/build.zig+14-7| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test the program"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | const dylib = b.addSharedLibrary(.{ | 18 | const dylib = b.addSharedLibrary(.{ |
| 11 | .name = "a", | 19 | .name = "a", |
| ... | @@ -15,7 +23,6 @@ pub fn build(b: *std.Build) void { | ... | @@ -15,7 +23,6 @@ pub fn build(b: *std.Build) void { |
| 15 | }); | 23 | }); |
| 16 | dylib.addCSourceFile("a.c", &.{}); | 24 | dylib.addCSourceFile("a.c", &.{}); |
| 17 | dylib.linkLibC(); | 25 | dylib.linkLibC(); |
| 18 | dylib.install(); | ||
| 19 | 26 | ||
| 20 | // -dead_strip_dylibs | 27 | // -dead_strip_dylibs |
| 21 | // -needed-la | 28 | // -needed-la |
| ... | @@ -27,8 +34,8 @@ pub fn build(b: *std.Build) void { | ... | @@ -27,8 +34,8 @@ pub fn build(b: *std.Build) void { |
| 27 | exe.addCSourceFile("main.c", &[0][]const u8{}); | 34 | exe.addCSourceFile("main.c", &[0][]const u8{}); |
| 28 | exe.linkLibC(); | 35 | exe.linkLibC(); |
| 29 | exe.linkSystemLibraryNeeded("a"); | 36 | exe.linkSystemLibraryNeeded("a"); |
| 30 | exe.addLibraryPath(b.pathFromRoot("zig-out/lib")); | 37 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); |
| 31 | exe.addRPath(b.pathFromRoot("zig-out/lib")); | 38 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); |
| 32 | exe.dead_strip_dylibs = true; | 39 | exe.dead_strip_dylibs = true; |
| 33 | 40 | ||
| 34 | const check = exe.checkObject(.macho); | 41 | const check = exe.checkObject(.macho); |
test/link/macho/objc/build.zig+11-2| ... | @@ -1,10 +1,19 @@ | ... | @@ -1,10 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | pub const requires_macos_sdk = true; | ||
| 5 | |||
| 3 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 8 | b.default_step = test_step; | ||
| 5 | 9 | ||
| 6 | const test_step = b.step("test", "Test the program"); | 10 | add(b, test_step, .Debug); |
| 11 | add(b, test_step, .ReleaseFast); | ||
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 7 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 8 | const exe = b.addExecutable(.{ | 17 | const exe = b.addExecutable(.{ |
| 9 | .name = "test", | 18 | .name = "test", |
| 10 | .optimize = optimize, | 19 | .optimize = optimize, |
test/link/macho/objcpp/build.zig+11-2| ... | @@ -1,10 +1,19 @@ | ... | @@ -1,10 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | pub const requires_macos_sdk = true; | ||
| 5 | |||
| 3 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 8 | b.default_step = test_step; | ||
| 5 | 9 | ||
| 6 | const test_step = b.step("test", "Test the program"); | 10 | add(b, test_step, .Debug); |
| 11 | add(b, test_step, .ReleaseFast); | ||
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 7 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 8 | const exe = b.addExecutable(.{ | 17 | const exe = b.addExecutable(.{ |
| 9 | .name = "test", | 18 | .name = "test", |
| 10 | .optimize = optimize, | 19 | .optimize = optimize, |
test/link/macho/pagezero/build.zig+6-4| ... | @@ -1,11 +1,13 @@ | ... | @@ -1,11 +1,13 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test"); | 9 | const optimize: std.builtin.OptimizeMode = .Debug; |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; |
| 9 | 11 | ||
| 10 | { | 12 | { |
| 11 | const exe = b.addExecutable(.{ | 13 | const exe = b.addExecutable(.{ |
test/link/macho/search_strategy/build.zig+23-18| ... | @@ -1,35 +1,41 @@ | ... | @@ -1,35 +1,41 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | { | 18 | { |
| 11 | // -search_dylibs_first | 19 | // -search_dylibs_first |
| 12 | const exe = createScenario(b, optimize, target); | 20 | const exe = createScenario(b, optimize, target, "search_dylibs_first"); |
| 13 | exe.search_strategy = .dylibs_first; | 21 | exe.search_strategy = .dylibs_first; |
| 14 | 22 | ||
| 15 | const check = exe.checkObject(.macho); | 23 | const check = exe.checkObject(.macho); |
| 16 | check.checkStart("cmd LOAD_DYLIB"); | 24 | check.checkStart("cmd LOAD_DYLIB"); |
| 17 | check.checkNext("name @rpath/liba.dylib"); | 25 | check.checkNext("name @rpath/libsearch_dylibs_first.dylib"); |
| 18 | 26 | ||
| 19 | const run = check.runAndCompare(); | 27 | const run = check.runAndCompare(); |
| 20 | run.cwd = b.pathFromRoot("."); | ||
| 21 | run.expectStdOutEqual("Hello world"); | 28 | run.expectStdOutEqual("Hello world"); |
| 22 | test_step.dependOn(&run.step); | 29 | test_step.dependOn(&run.step); |
| 23 | } | 30 | } |
| 24 | 31 | ||
| 25 | { | 32 | { |
| 26 | // -search_paths_first | 33 | // -search_paths_first |
| 27 | const exe = createScenario(b, optimize, target); | 34 | const exe = createScenario(b, optimize, target, "search_paths_first"); |
| 28 | exe.search_strategy = .paths_first; | 35 | exe.search_strategy = .paths_first; |
| 29 | 36 | ||
| 30 | const run = b.addRunArtifact(exe); | 37 | const run = b.addRunArtifact(exe); |
| 31 | run.skip_foreign_checks = true; | 38 | run.skip_foreign_checks = true; |
| 32 | run.cwd = b.pathFromRoot("."); | ||
| 33 | run.expectStdOutEqual("Hello world"); | 39 | run.expectStdOutEqual("Hello world"); |
| 34 | test_step.dependOn(&run.step); | 40 | test_step.dependOn(&run.step); |
| 35 | } | 41 | } |
| ... | @@ -39,9 +45,10 @@ fn createScenario( | ... | @@ -39,9 +45,10 @@ fn createScenario( |
| 39 | b: *std.Build, | 45 | b: *std.Build, |
| 40 | optimize: std.builtin.OptimizeMode, | 46 | optimize: std.builtin.OptimizeMode, |
| 41 | target: std.zig.CrossTarget, | 47 | target: std.zig.CrossTarget, |
| 48 | name: []const u8, | ||
| 42 | ) *std.Build.CompileStep { | 49 | ) *std.Build.CompileStep { |
| 43 | const static = b.addStaticLibrary(.{ | 50 | const static = b.addStaticLibrary(.{ |
| 44 | .name = "a", | 51 | .name = name, |
| 45 | .optimize = optimize, | 52 | .optimize = optimize, |
| 46 | .target = target, | 53 | .target = target, |
| 47 | }); | 54 | }); |
| ... | @@ -50,10 +57,9 @@ fn createScenario( | ... | @@ -50,10 +57,9 @@ fn createScenario( |
| 50 | static.override_dest_dir = std.Build.InstallDir{ | 57 | static.override_dest_dir = std.Build.InstallDir{ |
| 51 | .custom = "static", | 58 | .custom = "static", |
| 52 | }; | 59 | }; |
| 53 | static.install(); | ||
| 54 | 60 | ||
| 55 | const dylib = b.addSharedLibrary(.{ | 61 | const dylib = b.addSharedLibrary(.{ |
| 56 | .name = "a", | 62 | .name = name, |
| 57 | .version = .{ .major = 1, .minor = 0 }, | 63 | .version = .{ .major = 1, .minor = 0 }, |
| 58 | .optimize = optimize, | 64 | .optimize = optimize, |
| 59 | .target = target, | 65 | .target = target, |
| ... | @@ -63,18 +69,17 @@ fn createScenario( | ... | @@ -63,18 +69,17 @@ fn createScenario( |
| 63 | dylib.override_dest_dir = std.Build.InstallDir{ | 69 | dylib.override_dest_dir = std.Build.InstallDir{ |
| 64 | .custom = "dynamic", | 70 | .custom = "dynamic", |
| 65 | }; | 71 | }; |
| 66 | dylib.install(); | ||
| 67 | 72 | ||
| 68 | const exe = b.addExecutable(.{ | 73 | const exe = b.addExecutable(.{ |
| 69 | .name = "main", | 74 | .name = name, |
| 70 | .optimize = optimize, | 75 | .optimize = optimize, |
| 71 | .target = target, | 76 | .target = target, |
| 72 | }); | 77 | }); |
| 73 | exe.addCSourceFile("main.c", &.{}); | 78 | exe.addCSourceFile("main.c", &.{}); |
| 74 | exe.linkSystemLibraryName("a"); | 79 | exe.linkSystemLibraryName(name); |
| 75 | exe.linkLibC(); | 80 | exe.linkLibC(); |
| 76 | exe.addLibraryPath(b.pathFromRoot("zig-out/static")); | 81 | exe.addLibraryPathDirectorySource(static.getOutputDirectorySource()); |
| 77 | exe.addLibraryPath(b.pathFromRoot("zig-out/dynamic")); | 82 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); |
| 78 | exe.addRPath(b.pathFromRoot("zig-out/dynamic")); | 83 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); |
| 79 | return exe; | 84 | return exe; |
| 80 | } | 85 | } |
test/link/macho/stack_size/build.zig+12-4| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | const exe = b.addExecutable(.{ | 18 | const exe = b.addExecutable(.{ |
| 11 | .name = "main", | 19 | .name = "main", |
test/link/macho/strict_validation/build.zig+12-4| ... | @@ -1,12 +1,20 @@ | ... | @@ -1,12 +1,20 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub const requires_symlinks = true; | ||
| 5 | |||
| 4 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 5 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 6 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 8 | b.default_step = test_step; |
| 7 | 9 | ||
| 8 | const test_step = b.step("test", "Test"); | 10 | add(b, test_step, .Debug); |
| 9 | test_step.dependOn(b.getInstallStep()); | 11 | add(b, test_step, .ReleaseFast); |
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 15 | |||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 17 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 10 | 18 | ||
| 11 | const exe = b.addExecutable(.{ | 19 | const exe = b.addExecutable(.{ |
| 12 | .name = "main", | 20 | .name = "main", |
test/link/macho/tls/build.zig+12-2| ... | @@ -1,7 +1,18 @@ | ... | @@ -1,7 +1,18 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 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 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; |
| 6 | 17 | ||
| 7 | const lib = b.addSharedLibrary(.{ | 18 | const lib = b.addSharedLibrary(.{ |
| ... | @@ -21,6 +32,5 @@ pub fn build(b: *std.Build) void { | ... | @@ -21,6 +32,5 @@ pub fn build(b: *std.Build) void { |
| 21 | test_exe.linkLibrary(lib); | 32 | test_exe.linkLibrary(lib); |
| 22 | test_exe.linkLibC(); | 33 | test_exe.linkLibC(); |
| 23 | 34 | ||
| 24 | const test_step = b.step("test", "Test it"); | ||
| 25 | test_step.dependOn(&test_exe.step); | 35 | test_step.dependOn(&test_exe.step); |
| 26 | } | 36 | } |
test/link/macho/unwind_info/build.zig+18-7| ... | @@ -1,14 +1,23 @@ | ... | @@ -1,14 +1,23 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub const requires_symlinks = true; | ||
| 5 | |||
| 4 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 5 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 6 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 8 | b.default_step = test_step; |
| 7 | 9 | ||
| 8 | const test_step = b.step("test", "Test the program"); | 10 | add(b, test_step, .Debug); |
| 11 | add(b, test_step, .ReleaseFast); | ||
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 15 | |||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 17 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 18 | ||
| 10 | testUnwindInfo(b, test_step, optimize, target, false); | 19 | testUnwindInfo(b, test_step, optimize, target, false, "no-dead-strip"); |
| 11 | testUnwindInfo(b, test_step, optimize, target, true); | 20 | testUnwindInfo(b, test_step, optimize, target, true, "yes-dead-strip"); |
| 12 | } | 21 | } |
| 13 | 22 | ||
| 14 | fn testUnwindInfo( | 23 | fn testUnwindInfo( |
| ... | @@ -17,8 +26,9 @@ fn testUnwindInfo( | ... | @@ -17,8 +26,9 @@ fn testUnwindInfo( |
| 17 | optimize: std.builtin.OptimizeMode, | 26 | optimize: std.builtin.OptimizeMode, |
| 18 | target: std.zig.CrossTarget, | 27 | target: std.zig.CrossTarget, |
| 19 | dead_strip: bool, | 28 | dead_strip: bool, |
| 29 | name: []const u8, | ||
| 20 | ) void { | 30 | ) void { |
| 21 | const exe = createScenario(b, optimize, target); | 31 | const exe = createScenario(b, optimize, target, name); |
| 22 | exe.link_gc_sections = dead_strip; | 32 | exe.link_gc_sections = dead_strip; |
| 23 | 33 | ||
| 24 | const check = exe.checkObject(.macho); | 34 | const check = exe.checkObject(.macho); |
| ... | @@ -54,9 +64,10 @@ fn createScenario( | ... | @@ -54,9 +64,10 @@ fn createScenario( |
| 54 | b: *std.Build, | 64 | b: *std.Build, |
| 55 | optimize: std.builtin.OptimizeMode, | 65 | optimize: std.builtin.OptimizeMode, |
| 56 | target: std.zig.CrossTarget, | 66 | target: std.zig.CrossTarget, |
| 67 | name: []const u8, | ||
| 57 | ) *std.Build.CompileStep { | 68 | ) *std.Build.CompileStep { |
| 58 | const exe = b.addExecutable(.{ | 69 | const exe = b.addExecutable(.{ |
| 59 | .name = "test", | 70 | .name = name, |
| 60 | .optimize = optimize, | 71 | .optimize = optimize, |
| 61 | .target = target, | 72 | .target = target, |
| 62 | }); | 73 | }); |
test/link/macho/uuid/build.zig+5-2| ... | @@ -3,11 +3,14 @@ const CompileStep = std.Build.CompileStep; | ... | @@ -3,11 +3,14 @@ const CompileStep = std.Build.CompileStep; |
| 3 | const FileSource = std.Build.FileSource; | 3 | const FileSource = std.Build.FileSource; |
| 4 | const Step = std.Build.Step; | 4 | const Step = std.Build.Step; |
| 5 | 5 | ||
| 6 | pub const requires_symlinks = true; | ||
| 7 | |||
| 6 | pub fn build(b: *std.Build) void { | 8 | pub fn build(b: *std.Build) void { |
| 7 | const test_step = b.step("test", "Test"); | 9 | const test_step = b.step("test", "Test"); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | b.default_step = test_step; |
| 9 | 11 | ||
| 10 | // We force cross-compilation to ensure we always pick a generic CPU with constant set of CPU features. | 12 | // We force cross-compilation to ensure we always pick a generic CPU with |
| 13 | // constant set of CPU features. | ||
| 11 | const aarch64_macos = std.zig.CrossTarget{ | 14 | const aarch64_macos = std.zig.CrossTarget{ |
| 12 | .cpu_arch = .aarch64, | 15 | .cpu_arch = .aarch64, |
| 13 | .os_tag = .macos, | 16 | .os_tag = .macos, |
test/link/macho/weak_framework/build.zig+11-3| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | pub const requires_macos_sdk = true; | ||
| 5 | |||
| 3 | pub fn build(b: *std.Build) void { | 6 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 7 | const test_step = b.step("test", "Test it"); |
| 8 | b.default_step = test_step; | ||
| 5 | 9 | ||
| 6 | const test_step = b.step("test", "Test the program"); | 10 | add(b, test_step, .Debug); |
| 7 | test_step.dependOn(b.getInstallStep()); | 11 | add(b, test_step, .ReleaseFast); |
| 12 | add(b, test_step, .ReleaseSmall); | ||
| 13 | add(b, test_step, .ReleaseSafe); | ||
| 14 | } | ||
| 8 | 15 | ||
| 16 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 9 | const exe = b.addExecutable(.{ | 17 | const exe = b.addExecutable(.{ |
| 10 | .name = "test", | 18 | .name = "test", |
| 11 | .optimize = optimize, | 19 | .optimize = optimize, |
test/link/macho/weak_library/build.zig+14-6| ... | @@ -1,11 +1,19 @@ | ... | @@ -1,11 +1,19 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub const requires_symlinks = true; | ||
| 4 | |||
| 3 | pub fn build(b: *std.Build) void { | 5 | pub fn build(b: *std.Build) void { |
| 4 | const optimize = b.standardOptimizeOption(.{}); | 6 | const test_step = b.step("test", "Test it"); |
| 5 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | 7 | b.default_step = test_step; |
| 6 | 8 | ||
| 7 | const test_step = b.step("test", "Test the program"); | 9 | add(b, test_step, .Debug); |
| 8 | test_step.dependOn(b.getInstallStep()); | 10 | add(b, test_step, .ReleaseFast); |
| 11 | add(b, test_step, .ReleaseSmall); | ||
| 12 | add(b, test_step, .ReleaseSafe); | ||
| 13 | } | ||
| 14 | |||
| 15 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | ||
| 16 | const target: std.zig.CrossTarget = .{ .os_tag = .macos }; | ||
| 9 | 17 | ||
| 10 | const dylib = b.addSharedLibrary(.{ | 18 | const dylib = b.addSharedLibrary(.{ |
| 11 | .name = "a", | 19 | .name = "a", |
| ... | @@ -25,8 +33,8 @@ pub fn build(b: *std.Build) void { | ... | @@ -25,8 +33,8 @@ pub fn build(b: *std.Build) void { |
| 25 | exe.addCSourceFile("main.c", &[0][]const u8{}); | 33 | exe.addCSourceFile("main.c", &[0][]const u8{}); |
| 26 | exe.linkLibC(); | 34 | exe.linkLibC(); |
| 27 | exe.linkSystemLibraryWeak("a"); | 35 | exe.linkSystemLibraryWeak("a"); |
| 28 | exe.addLibraryPath(b.pathFromRoot("zig-out/lib")); | 36 | exe.addLibraryPathDirectorySource(dylib.getOutputDirectorySource()); |
| 29 | exe.addRPath(b.pathFromRoot("zig-out/lib")); | 37 | exe.addRPathDirectorySource(dylib.getOutputDirectorySource()); |
| 30 | 38 | ||
| 31 | const check = exe.checkObject(.macho); | 39 | const check = exe.checkObject(.macho); |
| 32 | check.checkStart("cmd LOAD_WEAK_DYLIB"); | 40 | check.checkStart("cmd LOAD_WEAK_DYLIB"); |
test/tests.zig+10-8| ... | @@ -590,23 +590,25 @@ pub fn addStandaloneTests( | ... | @@ -590,23 +590,25 @@ pub fn addStandaloneTests( |
| 590 | 590 | ||
| 591 | pub fn addLinkTests( | 591 | pub fn addLinkTests( |
| 592 | b: *std.Build, | 592 | b: *std.Build, |
| 593 | test_filter: ?[]const u8, | ||
| 594 | optimize_modes: []const OptimizeMode, | ||
| 595 | enable_macos_sdk: bool, | 593 | enable_macos_sdk: bool, |
| 596 | omit_stage2: bool, | 594 | omit_stage2: bool, |
| 597 | enable_symlinks_windows: bool, | 595 | enable_symlinks_windows: bool, |
| 598 | ) *Step { | 596 | ) *Step { |
| 599 | _ = test_filter; | ||
| 600 | _ = optimize_modes; | ||
| 601 | _ = enable_macos_sdk; | ||
| 602 | _ = enable_symlinks_windows; | ||
| 603 | |||
| 604 | const step = b.step("test-link", "Run the linker tests"); | 597 | const step = b.step("test-link", "Run the linker tests"); |
| 598 | const omit_symlinks = builtin.os.tag == .windows and !enable_symlinks_windows; | ||
| 605 | 599 | ||
| 606 | inline for (link.cases) |link_test| { | 600 | inline for (link.cases) |link_test| { |
| 607 | const requires_stage2 = @hasDecl(link_test.import, "requires_stage2") and | 601 | const requires_stage2 = @hasDecl(link_test.import, "requires_stage2") and |
| 608 | link_test.import.requires_stage2; | 602 | link_test.import.requires_stage2; |
| 609 | if (!requires_stage2 or !omit_stage2) { | 603 | const requires_symlinks = @hasDecl(link_test.import, "requires_symlinks") and |
| 604 | link_test.import.requires_symlinks; | ||
| 605 | const requires_macos_sdk = @hasDecl(link_test.import, "requires_macos_sdk") and | ||
| 606 | link_test.import.requires_macos_sdk; | ||
| 607 | const bad = | ||
| 608 | (requires_stage2 and omit_stage2) or | ||
| 609 | (requires_symlinks and omit_symlinks) or | ||
| 610 | (requires_macos_sdk and !enable_macos_sdk); | ||
| 611 | if (!bad) { | ||
| 610 | const dep = b.anonymousDependency(link_test.build_root, link_test.import, .{}); | 612 | const dep = b.anonymousDependency(link_test.build_root, link_test.import, .{}); |
| 611 | const dep_step = dep.builder.default_step; | 613 | const dep_step = dep.builder.default_step; |
| 612 | assert(mem.startsWith(u8, dep.builder.dep_prefix, "test.")); | 614 | assert(mem.startsWith(u8, dep.builder.dep_prefix, "test.")); |