| ... | ... | @@ -35,6 +35,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 35 | 35 | |
| 36 | 36 | // Tests requiring symlinks when tested on Windows |
| 37 | 37 | if (build_opts.has_symlinks_windows) { |
| 38 | macho_step.dependOn(testDylib(b, .{ .target = default_target })); |
| 38 | 39 | macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); |
| 39 | 40 | macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); |
| 40 | 41 | macho_step.dependOn(testTls(b, .{ .target = default_target })); |
| ... | ... | @@ -182,6 +183,43 @@ fn testDeadStripDylibs(b: *Build, opts: Options) *Step { |
| 182 | 183 | return test_step; |
| 183 | 184 | } |
| 184 | 185 | |
| 186 | fn testDylib(b: *Build, opts: Options) *Step { |
| 187 | const test_step = addTestStep(b, "macho-dylib", opts); |
| 188 | |
| 189 | const dylib = addSharedLibrary(b, opts, .{ .name = "a", .c_source_bytes = |
| 190 | \\#include<stdio.h> |
| 191 | \\char world[] = "world"; |
| 192 | \\char* hello() { |
| 193 | \\ return "Hello"; |
| 194 | \\} |
| 195 | }); |
| 196 | |
| 197 | const check = dylib.checkObject(); |
| 198 | check.checkInHeaders(); |
| 199 | check.checkExact("header"); |
| 200 | check.checkNotPresent("PIE"); |
| 201 | test_step.dependOn(&check.step); |
| 202 | |
| 203 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = |
| 204 | \\#include<stdio.h> |
| 205 | \\char* hello(); |
| 206 | \\extern char world[]; |
| 207 | \\int main() { |
| 208 | \\ printf("%s %s", hello(), world); |
| 209 | \\ return 0; |
| 210 | \\} |
| 211 | }); |
| 212 | exe.root_module.linkSystemLibrary("a", .{}); |
| 213 | exe.addLibraryPath(dylib.getEmittedBinDirectory()); |
| 214 | exe.addRPath(dylib.getEmittedBinDirectory()); |
| 215 | |
| 216 | const run = addRunArtifact(exe); |
| 217 | run.expectStdOutEqual("Hello world"); |
| 218 | test_step.dependOn(&run.step); |
| 219 | |
| 220 | return test_step; |
| 221 | } |
| 222 | |
| 185 | 223 | fn testEntryPointDylib(b: *Build, opts: Options) *Step { |
| 186 | 224 | const test_step = addTestStep(b, "macho-entry-point-dylib", opts); |
| 187 | 225 | |