diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-07-16 21:13:57 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-07-18 09:13:09 +0200 |
| commit | 34f34dbe3246547d4586d284cf44510e3f8feaa2 (patch) | |
| tree | 05602e26db6b788edc0e74eaa7b70ac98346de64 /test | |
| parent | d19aab2e872df58c56a17ca7b9ee1ea9aab82b99 (diff) | |
| download | zig-34f34dbe3246547d4586d284cf44510e3f8feaa2.tar.gz zig-34f34dbe3246547d4586d284cf44510e3f8feaa2.zip | |
macho: reinstate duplicate definition checking
Diffstat (limited to 'test')
| -rw-r--r-- | test/link/macho.zig | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/link/macho.zig b/test/link/macho.zig index 6c047ee322..12f4d9b492 100644 --- a/test/link/macho.zig +++ b/test/link/macho.zig @@ -30,6 +30,7 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step { // Exercise linker with LLVM backend macho_step.dependOn(testDeadStrip(b, .{ .target = default_target })); + macho_step.dependOn(testDuplicateDefinitions(b, .{ .target = default_target })); macho_step.dependOn(testEmptyObject(b, .{ .target = default_target })); macho_step.dependOn(testEmptyZig(b, .{ .target = default_target })); macho_step.dependOn(testEntryPoint(b, .{ .target = default_target })); @@ -182,6 +183,37 @@ fn testDeadStrip(b: *Build, opts: Options) *Step { return test_step; } +fn testDuplicateDefinitions(b: *Build, opts: Options) *Step { + const test_step = addTestStep(b, "duplicate-definitions", opts); + + const obj = addObject(b, opts, .{ .name = "a", .zig_source_bytes = + \\var x: usize = 1; + \\export fn strong() void { x += 1; } + \\export fn weak() void { x += 1; } + }); + + const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes = + \\var x: usize = 1; + \\export fn strong() void { x += 1; } + \\comptime { @export(weakImpl, .{ .name = "weak", .linkage = .weak }); } + \\fn weakImpl() callconv(.C) void { x += 1; } + \\extern fn weak() void; + \\pub fn main() void { + \\ weak(); + \\ strong(); + \\} + }); + exe.addObject(obj); + + expectLinkErrors(exe, test_step, .{ .exact = &.{ + "error: duplicate symbol definition: _strong", + "note: defined by /?/a.o", + "note: defined by /?/main.o", + } }); + + return test_step; +} + fn testDeadStripDylibs(b: *Build, opts: Options) *Step { const test_step = addTestStep(b, "dead-strip-dylibs", opts); |
