| ... | @@ -18,7 +18,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { | ... | @@ -18,7 +18,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 18 | | 18 | |
| 19 | macho_step.dependOn(testDeadStrip(b, .{ .target = default_target })); | 19 | macho_step.dependOn(testDeadStrip(b, .{ .target = default_target })); |
| 20 | macho_step.dependOn(testEmptyObject(b, .{ .target = default_target })); | 20 | macho_step.dependOn(testEmptyObject(b, .{ .target = default_target })); |
| 21 | macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target })); | 21 | macho_step.dependOn(testEntryPoint(b, .{ .target = default_target })); |
| 22 | macho_step.dependOn(testHeaderWeakFlags(b, .{ .target = default_target })); | 22 | macho_step.dependOn(testHeaderWeakFlags(b, .{ .target = default_target })); |
| 23 | macho_step.dependOn(testHelloC(b, .{ .target = default_target })); | 23 | macho_step.dependOn(testHelloC(b, .{ .target = default_target })); |
| 24 | macho_step.dependOn(testHelloZig(b, .{ .target = default_target })); | 24 | macho_step.dependOn(testHelloZig(b, .{ .target = default_target })); |
| ... | @@ -36,6 +36,8 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { | ... | @@ -36,6 +36,8 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 36 | | 36 | |
| 37 | // Tests requiring symlinks when tested on Windows | 37 | // Tests requiring symlinks when tested on Windows |
| 38 | if (build_opts.has_symlinks_windows) { | 38 | if (build_opts.has_symlinks_windows) { |
| | 39 | macho_step.dependOn(testEntryPointArchive(b, .{ .target = default_target })); |
| | 40 | macho_step.dependOn(testEntryPointDylib(b, .{ .target = default_target })); |
| 39 | macho_step.dependOn(testDylib(b, .{ .target = default_target })); | 41 | macho_step.dependOn(testDylib(b, .{ .target = default_target })); |
| 40 | macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); | 42 | macho_step.dependOn(testNeededLibrary(b, .{ .target = default_target })); |
| 41 | macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); | 43 | macho_step.dependOn(testWeakLibrary(b, .{ .target = default_target })); |
| ... | @@ -241,6 +243,64 @@ fn testEmptyObject(b: *Build, opts: Options) *Step { | ... | @@ -241,6 +243,64 @@ fn testEmptyObject(b: *Build, opts: Options) *Step { |
| 241 | return test_step; | 243 | return test_step; |
| 242 | } | 244 | } |
| 243 | | 245 | |
| | 246 | fn testEntryPoint(b: *Build, opts: Options) *Step { |
| | 247 | const test_step = addTestStep(b, "macho-entry-point", opts); |
| | 248 | |
| | 249 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = |
| | 250 | \\#include<stdio.h> |
| | 251 | \\int non_main() { |
| | 252 | \\ printf("%d", 42); |
| | 253 | \\ return 0; |
| | 254 | \\} |
| | 255 | }); |
| | 256 | exe.entry = .{ .symbol_name = "_non_main" }; |
| | 257 | |
| | 258 | const run = addRunArtifact(exe); |
| | 259 | run.expectStdOutEqual("42"); |
| | 260 | test_step.dependOn(&run.step); |
| | 261 | |
| | 262 | const check = exe.checkObject(); |
| | 263 | check.checkInHeaders(); |
| | 264 | check.checkExact("segname __TEXT"); |
| | 265 | check.checkExtract("vmaddr {vmaddr}"); |
| | 266 | check.checkInHeaders(); |
| | 267 | check.checkExact("cmd MAIN"); |
| | 268 | check.checkExtract("entryoff {entryoff}"); |
| | 269 | check.checkInSymtab(); |
| | 270 | check.checkExtract("{n_value} (__TEXT,__text) external _non_main"); |
| | 271 | check.checkComputeCompare("vmaddr entryoff +", .{ .op = .eq, .value = .{ .variable = "n_value" } }); |
| | 272 | test_step.dependOn(&check.step); |
| | 273 | |
| | 274 | return test_step; |
| | 275 | } |
| | 276 | |
| | 277 | fn testEntryPointArchive(b: *Build, opts: Options) *Step { |
| | 278 | const test_step = addTestStep(b, "macho-entry-point-archive", opts); |
| | 279 | |
| | 280 | const lib = addStaticLibrary(b, opts, .{ .name = "main", .c_source_bytes = "int main() { return 0; }" }); |
| | 281 | |
| | 282 | { |
| | 283 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "" }); |
| | 284 | exe.root_module.linkSystemLibrary("main", .{}); |
| | 285 | exe.addLibraryPath(lib.getEmittedBinDirectory()); |
| | 286 | |
| | 287 | const run = addRunArtifact(exe); |
| | 288 | test_step.dependOn(&run.step); |
| | 289 | } |
| | 290 | |
| | 291 | { |
| | 292 | const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes = "" }); |
| | 293 | exe.root_module.linkSystemLibrary("main", .{}); |
| | 294 | exe.addLibraryPath(lib.getEmittedBinDirectory()); |
| | 295 | exe.link_gc_sections = true; |
| | 296 | |
| | 297 | const run = addRunArtifact(exe); |
| | 298 | test_step.dependOn(&run.step); |
| | 299 | } |
| | 300 | |
| | 301 | return test_step; |
| | 302 | } |
| | 303 | |
| 244 | fn testEntryPointDylib(b: *Build, opts: Options) *Step { | 304 | fn testEntryPointDylib(b: *Build, opts: Options) *Step { |
| 245 | const test_step = addTestStep(b, "macho-entry-point-dylib", opts); | 305 | const test_step = addTestStep(b, "macho-entry-point-dylib", opts); |
| 246 | | 306 | |