| author | |
| committer | |
| log | 2b3ac3e82f4207981469739b4ecd9fa0c3ac3308 |
| tree | 92d69521c967826a29b78d0a1302eb0eeff22f99 |
| parent | a3f68c6fa23f893597b7708e0c00e81f57cb35c1 |
5 files changed, 39 insertions(+), 71 deletions(-)
test/link.zig-4| ... | ... | @@ -115,8 +115,4 @@ pub const cases = [_]Case{ |
| 115 | 115 | .build_root = "test/link/macho/objcpp", |
| 116 | 116 | .import = @import("link/macho/objcpp/build.zig"), |
| 117 | 117 | }, |
| 118 | .{ | |
| 119 | .build_root = "test/link/macho/tbdv3", | |
| 120 | .import = @import("link/macho/tbdv3/build.zig"), | |
| 121 | }, | |
| 122 | 118 | }; |
test/link/macho.zig+39| ... | ... | @@ -50,6 +50,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 50 | 50 | macho_step.dependOn(testDylib(b, .{ .target = default_target })); |
| 51 | 51 | macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); |
| 52 | 52 | macho_step.dependOn(testSearchStrategy(b, .{ .target = default_target })); |
| 53 | macho_step.dependOn(testTbdv3(b, .{ .target = default_target })); | |
| 53 | 54 | macho_step.dependOn(testTls(b, .{ .target = default_target })); |
| 54 | 55 | macho_step.dependOn(testTwoLevelNamespace(b, .{ .target = default_target })); |
| 55 | 56 | macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); |
| ... | ... | @@ -1285,6 +1286,44 @@ fn testStackSize(b: *Build, opts: Options) *Step { |
| 1285 | 1286 | return test_step; |
| 1286 | 1287 | } |
| 1287 | 1288 | |
| 1289 | fn testTbdv3(b: *Build, opts: Options) *Step { | |
| 1290 | const test_step = addTestStep(b, "macho-tbdv3", opts); | |
| 1291 | ||
| 1292 | const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes = "int getFoo() { return 42; }" }); | |
| 1293 | ||
| 1294 | const tbd = tbd: { | |
| 1295 | const wf = WriteFile.create(b); | |
| 1296 | break :tbd wf.add("liba.tbd", | |
| 1297 | \\--- !tapi-tbd-v3 | |
| 1298 | \\archs: [ arm64, x86_64 ] | |
| 1299 | \\uuids: [ 'arm64: DEADBEEF', 'x86_64: BEEFDEAD' ] | |
| 1300 | \\platform: macos | |
| 1301 | \\install-name: @rpath/liba.dylib | |
| 1302 | \\current-version: 0 | |
| 1303 | \\exports: | |
| 1304 | \\ - archs: [ arm64, x86_64 ] | |
| 1305 | \\ symbols: [ _getFoo ] | |
| 1306 | ); | |
| 1307 | }; | |
| 1308 | ||
| 1309 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = | |
| 1310 | \\#include <stdio.h> | |
| 1311 | \\int getFoo(); | |
| 1312 | \\int main() { | |
| 1313 | \\ return getFoo() - 42; | |
| 1314 | \\} | |
| 1315 | }); | |
| 1316 | exe.root_module.linkSystemLibrary("a", .{}); | |
| 1317 | exe.root_module.addLibraryPath(tbd.dirname()); | |
| 1318 | exe.root_module.addRPath(dylib.getEmittedBinDirectory()); | |
| 1319 | ||
| 1320 | const run = addRunArtifact(exe); | |
| 1321 | run.expectExitCode(0); | |
| 1322 | test_step.dependOn(&run.step); | |
| 1323 | ||
| 1324 | return test_step; | |
| 1325 | } | |
| 1326 | ||
| 1288 | 1327 | fn testTentative(b: *Build, opts: Options) *Step { |
| 1289 | 1328 | const test_step = addTestStep(b, "macho-tentative", opts); |
| 1290 | 1329 |
test/link/macho/tbdv3/a.c deleted-3| ... | ... | @@ -1,3 +0,0 @@ |
| 1 | int getFoo() { | |
| 2 | return 42; | |
| 3 | } |
test/link/macho/tbdv3/build.zig deleted-57| ... | ... | @@ -1,57 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | ||
| 4 | pub const requires_symlinks = true; | |
| 5 | pub const requires_macos_sdk = false; | |
| 6 | ||
| 7 | pub fn build(b: *std.Build) void { | |
| 8 | const test_step = b.step("test", "Test it"); | |
| 9 | b.default_step = test_step; | |
| 10 | ||
| 11 | add(b, test_step, .Debug); | |
| 12 | add(b, test_step, .ReleaseFast); | |
| 13 | add(b, test_step, .ReleaseSmall); | |
| 14 | add(b, test_step, .ReleaseSafe); | |
| 15 | } | |
| 16 | ||
| 17 | fn add(b: *std.Build, test_step: *std.Build.Step, optimize: std.builtin.OptimizeMode) void { | |
| 18 | const target = b.resolveTargetQuery(.{ .os_tag = .macos }); | |
| 19 | ||
| 20 | const lib = b.addSharedLibrary(.{ | |
| 21 | .name = "a", | |
| 22 | .version = .{ .major = 1, .minor = 0, .patch = 0 }, | |
| 23 | .optimize = optimize, | |
| 24 | .target = target, | |
| 25 | }); | |
| 26 | lib.addCSourceFile(.{ .file = .{ .path = "a.c" }, .flags = &.{} }); | |
| 27 | lib.linkLibC(); | |
| 28 | ||
| 29 | const tbd_file = b.addWriteFile("liba.tbd", | |
| 30 | \\--- !tapi-tbd-v3 | |
| 31 | \\archs: [ arm64, x86_64 ] | |
| 32 | \\uuids: [ 'arm64: DEADBEEF', 'x86_64: BEEFDEAD' ] | |
| 33 | \\platform: macos | |
| 34 | \\install-name: @rpath/liba.dylib | |
| 35 | \\current-version: 0 | |
| 36 | \\exports: | |
| 37 | \\ - archs: [ arm64, x86_64 ] | |
| 38 | \\ symbols: [ _getFoo ] | |
| 39 | ); | |
| 40 | ||
| 41 | const exe = b.addExecutable(.{ | |
| 42 | .name = "test", | |
| 43 | .optimize = optimize, | |
| 44 | .target = target, | |
| 45 | }); | |
| 46 | exe.addCSourceFile(.{ .file = .{ .path = "main.c" }, .flags = &[0][]const u8{} }); | |
| 47 | exe.linkSystemLibrary("a"); | |
| 48 | exe.addLibraryPath(tbd_file.getDirectory()); | |
| 49 | exe.addRPath(lib.getEmittedBinDirectory()); | |
| 50 | exe.linkLibC(); | |
| 51 | ||
| 52 | const run = b.addRunArtifact(exe); | |
| 53 | run.skip_foreign_checks = true; | |
| 54 | run.expectExitCode(0); | |
| 55 | ||
| 56 | test_step.dependOn(&run.step); | |
| 57 | } |
test/link/macho/tbdv3/main.c deleted-7| ... | ... | @@ -1,7 +0,0 @@ |
| 1 | #include <stdio.h> | |
| 2 | ||
| 3 | int getFoo(); | |
| 4 | ||
| 5 | int main() { | |
| 6 | return getFoo() - 42; | |
| 7 | } |