| ... | ... | @@ -16,7 +16,10 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 16 | 16 | }); |
| 17 | 17 | |
| 18 | 18 | // Exercise linker with self-hosted backend (no LLVM) |
| 19 | macho_step.dependOn(testEmptyZig(b, .{ .use_llvm = false, .target = x86_64_target })); |
| 19 | 20 | macho_step.dependOn(testHelloZig(b, .{ .use_llvm = false, .target = x86_64_target })); |
| 21 | macho_step.dependOn(testLinkingStaticLib(b, .{ .use_llvm = false, .target = x86_64_target })); |
| 22 | macho_step.dependOn(testReexportsZig(b, .{ .use_llvm = false, .target = x86_64_target })); |
| 20 | 23 | macho_step.dependOn(testRelocatableZig(b, .{ .use_llvm = false, .target = x86_64_target })); |
| 21 | 24 | |
| 22 | 25 | // Exercise linker with LLVM backend |
| ... | ... | @@ -29,6 +32,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { |
| 29 | 32 | macho_step.dependOn(testHelloZig(b, .{ .target = default_target })); |
| 30 | 33 | macho_step.dependOn(testLargeBss(b, .{ .target = default_target })); |
| 31 | 34 | macho_step.dependOn(testLayout(b, .{ .target = default_target })); |
| 35 | macho_step.dependOn(testLinkingStaticLib(b, .{ .target = default_target })); |
| 32 | 36 | macho_step.dependOn(testLinksection(b, .{ .target = default_target })); |
| 33 | 37 | macho_step.dependOn(testMhExecuteHeader(b, .{ .target = default_target })); |
| 34 | 38 | macho_step.dependOn(testNoDeadStrip(b, .{ .target = default_target })); |
| ... | ... | @@ -839,6 +843,44 @@ fn testLinkDirectlyCppTbd(b: *Build, opts: Options) *Step { |
| 839 | 843 | return test_step; |
| 840 | 844 | } |
| 841 | 845 | |
| 846 | fn testLinkingStaticLib(b: *Build, opts: Options) *Step { |
| 847 | const test_step = addTestStep(b, "linking-static-lib", opts); |
| 848 | |
| 849 | const obj = addObject(b, opts, .{ |
| 850 | .name = "bobj", |
| 851 | .zig_source_bytes = "export var bar: i32 = -42;", |
| 852 | }); |
| 853 | |
| 854 | const lib = addStaticLibrary(b, opts, .{ |
| 855 | .name = "alib", |
| 856 | .zig_source_bytes = |
| 857 | \\export fn foo() i32 { |
| 858 | \\ return 42; |
| 859 | \\} |
| 860 | , |
| 861 | }); |
| 862 | lib.addObject(obj); |
| 863 | |
| 864 | const exe = addExecutable(b, opts, .{ |
| 865 | .name = "testlib", |
| 866 | .zig_source_bytes = |
| 867 | \\const std = @import("std"); |
| 868 | \\extern fn foo() i32; |
| 869 | \\extern var bar: i32; |
| 870 | \\pub fn main() void { |
| 871 | \\ std.debug.print("{d}\n", .{foo() + bar}); |
| 872 | \\} |
| 873 | , |
| 874 | }); |
| 875 | exe.linkLibrary(lib); |
| 876 | |
| 877 | const run = addRunArtifact(exe); |
| 878 | run.expectStdErrEqual("0\n"); |
| 879 | test_step.dependOn(&run.step); |
| 880 | |
| 881 | return test_step; |
| 882 | } |
| 883 | |
| 842 | 884 | fn testLinksection(b: *Build, opts: Options) *Step { |
| 843 | 885 | const test_step = addTestStep(b, "macho-linksection", opts); |
| 844 | 886 | |
| ... | ... | @@ -1239,14 +1281,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step { |
| 1239 | 1281 | const run = addRunArtifact(exe); |
| 1240 | 1282 | run.addCheck(.{ .expect_stderr_match = b.dupe("incrFoo=1") }); |
| 1241 | 1283 | run.addCheck(.{ .expect_stderr_match = b.dupe("decrFoo=0") }); |
| 1242 | | if (opts.use_llvm) { |
| 1243 | | // TODO: enable this once self-hosted can print panics and stack traces |
| 1244 | | run.addCheck(.{ .expect_stderr_match = b.dupe("panic: Oh no!") }); |
| 1245 | | } |
| 1246 | | if (builtin.os.tag == .macos) { |
| 1247 | | const signal: u32 = if (opts.use_llvm) std.os.darwin.SIG.ABRT else std.os.darwin.SIG.TRAP; |
| 1248 | | run.addCheck(.{ .expect_term = .{ .Signal = signal } }); |
| 1249 | | } |
| 1284 | run.addCheck(.{ .expect_stderr_match = b.dupe("panic: Oh no!") }); |
| 1250 | 1285 | test_step.dependOn(&run.step); |
| 1251 | 1286 | |
| 1252 | 1287 | return test_step; |