From 33401ff3bb9359c656d21d2b1a0277c9fc5b85d1 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 9 Oct 2024 21:39:13 +0200 Subject: [PATCH] test/link/macho: test reporting undefined special symbols --- test/link/macho.zig | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/link/macho.zig b/test/link/macho.zig index 31e6de1d04..1d790b20c6 100644 --- a/test/link/macho.zig +++ b/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);