Commit 33401ff3bb

Jakub Konka <kubkon@jakubkonka.com>
2024-10-09 21:39:13
test/link/macho: test reporting undefined special symbols
1 parent d43b0cb
Changed files (1)
test
test/link/macho.zig
@@ -63,6 +63,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
     macho_step.dependOn(testTlsZig(b, .{ .target = default_target }));
     macho_step.dependOn(testUndefinedFlag(b, .{ .target = default_target }));
     macho_step.dependOn(testUnresolvedError(b, .{ .target = default_target }));
+    macho_step.dependOn(testUnresolvedError2(b, .{ .target = default_target }));
     macho_step.dependOn(testUnwindInfo(b, .{ .target = default_target }));
     macho_step.dependOn(testUnwindInfoNoSubsectionsX64(b, .{ .target = x86_64_target }));
     macho_step.dependOn(testUnwindInfoNoSubsectionsArm64(b, .{ .target = aarch64_target }));
@@ -2610,6 +2611,31 @@ fn testUnresolvedError(b: *Build, opts: Options) *Step {
     return test_step;
 }
 
+fn testUnresolvedError2(b: *Build, opts: Options) *Step {
+    const test_step = addTestStep(b, "unresolved-error-2", opts);
+
+    const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes = 
+    \\pub fn main() !void {
+    \\    const msg_send_fn = @extern(
+    \\        *const fn () callconv(.C) usize,
+    \\        .{ .name = "objc_msgSend$initWithContentRect:styleMask:backing:defer:screen:" },
+    \\    );
+    \\    _ = @call(
+    \\        .auto,
+    \\        msg_send_fn,
+    \\        .{},
+    \\    );
+    \\}
+    });
+
+    expectLinkErrors(exe, test_step, .{ .exact = &.{
+        "error: undefined symbol: _objc_msgSend",
+        "note: referenced implicitly",
+    } });
+
+    return test_step;
+}
+
 fn testUnwindInfo(b: *Build, opts: Options) *Step {
     const test_step = addTestStep(b, "unwind-info", opts);