| ... | @@ -45,9 +45,10 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { | ... | @@ -45,9 +45,10 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 45 | macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target })); | 45 | macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target })); |
| 46 | macho_step.dependOn(testDylib(b, .{ .target = default_target })); | 46 | macho_step.dependOn(testDylib(b, .{ .target = default_target })); |
| 47 | macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); | 47 | macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); |
| 48 | macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); | 48 | macho_step.dependOn(testSearchStrategy(b, .{ .target = b.host })); |
| 49 | macho_step.dependOn(testTls(b, .{ .target = default_target })); | 49 | macho_step.dependOn(testTls(b, .{ .target = default_target })); |
| 50 | macho_step.dependOn(testTwoLevelNamespace(b, .{ .target = default_target })); | 50 | macho_step.dependOn(testTwoLevelNamespace(b, .{ .target = default_target })); |
| | 51 | macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); |
| 51 | | 52 | |
| 52 | // Tests requiring presence of macOS SDK in system path | 53 | // Tests requiring presence of macOS SDK in system path |
| 53 | if (build_opts.has_macos_sdk) { | 54 | if (build_opts.has_macos_sdk) { |
| ... | @@ -1046,6 +1047,74 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step { | ... | @@ -1046,6 +1047,74 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step { |
| 1046 | return test_step; | 1047 | return test_step; |
| 1047 | } | 1048 | } |
| 1048 | | 1049 | |
| | 1050 | fn testSearchStrategy(b: *Build, opts: Options) *Step { |
| | 1051 | const test_step = addTestStep(b, "macho-search-strategy", opts); |
| | 1052 | |
| | 1053 | const obj = addObject(b, opts, .{ .name = "a", .c_source_bytes = |
| | 1054 | \\#include<stdio.h> |
| | 1055 | \\char world[] = "world"; |
| | 1056 | \\char* hello() { |
| | 1057 | \\ return "Hello"; |
| | 1058 | \\} |
| | 1059 | }); |
| | 1060 | |
| | 1061 | const liba = addStaticLibrary(b, opts, .{ .name = "a" }); |
| | 1062 | liba.addObject(obj); |
| | 1063 | |
| | 1064 | const dylib = addSharedLibrary(b, opts, .{ .name = "a" }); |
| | 1065 | dylib.addObject(obj); |
| | 1066 | |
| | 1067 | const main_o = addObject(b, opts, .{ .name = "main", .c_source_bytes = |
| | 1068 | \\#include<stdio.h> |
| | 1069 | \\char* hello(); |
| | 1070 | \\extern char world[]; |
| | 1071 | \\int main() { |
| | 1072 | \\ printf("%s %s", hello(), world); |
| | 1073 | \\ return 0; |
| | 1074 | \\} |
| | 1075 | }); |
| | 1076 | |
| | 1077 | { |
| | 1078 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| | 1079 | exe.addObject(main_o); |
| | 1080 | exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .mode_first }); |
| | 1081 | exe.root_module.addLibraryPath(liba.getEmittedBinDirectory()); |
| | 1082 | exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory()); |
| | 1083 | exe.root_module.addRPath(dylib.getEmittedBinDirectory()); |
| | 1084 | |
| | 1085 | const run = addRunArtifact(exe); |
| | 1086 | run.expectStdOutEqual("Hello world"); |
| | 1087 | test_step.dependOn(&run.step); |
| | 1088 | |
| | 1089 | const check = exe.checkObject(); |
| | 1090 | check.checkInHeaders(); |
| | 1091 | check.checkExact("cmd LOAD_DYLIB"); |
| | 1092 | check.checkContains("liba.dylib"); |
| | 1093 | test_step.dependOn(&check.step); |
| | 1094 | } |
| | 1095 | |
| | 1096 | { |
| | 1097 | const exe = addExecutable(b, opts, .{ .name = "main" }); |
| | 1098 | exe.addObject(main_o); |
| | 1099 | exe.root_module.linkSystemLibrary("a", .{ .use_pkg_config = .no, .search_strategy = .paths_first }); |
| | 1100 | exe.root_module.addLibraryPath(liba.getEmittedBinDirectory()); |
| | 1101 | exe.root_module.addLibraryPath(dylib.getEmittedBinDirectory()); |
| | 1102 | exe.root_module.addRPath(dylib.getEmittedBinDirectory()); |
| | 1103 | |
| | 1104 | const run = addRunArtifact(exe); |
| | 1105 | run.expectStdOutEqual("Hello world"); |
| | 1106 | test_step.dependOn(&run.step); |
| | 1107 | |
| | 1108 | const check = exe.checkObject(); |
| | 1109 | check.checkInHeaders(); |
| | 1110 | check.checkExact("cmd LOAD_DYLIB"); |
| | 1111 | check.checkNotPresent("liba.dylib"); |
| | 1112 | test_step.dependOn(&check.step); |
| | 1113 | } |
| | 1114 | |
| | 1115 | return test_step; |
| | 1116 | } |
| | 1117 | |
| 1049 | fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step { | 1118 | fn testSectionBoundarySymbols(b: *Build, opts: Options) *Step { |
| 1050 | const test_step = addTestStep(b, "macho-section-boundary-symbols", opts); | 1119 | const test_step = addTestStep(b, "macho-section-boundary-symbols", opts); |
| 1051 | | 1120 | |