diff --git a/src/Zcu/PerThread.zig b/src/Zcu/PerThread.zig index f0b1764f463dbe9d085e0fca931d20286e99255f..6635be1a1428d9971b6d23f8b0d61c2ec401681b 100644 --- a/src/Zcu/PerThread.zig +++ b/src/Zcu/PerThread.zig @@ -3655,6 +3655,10 @@ pub fn processExports(pt: Zcu.PerThread) (Allocator.Error || Io.Cancelable)!void for (alive_exports.items) |export_index| { const exp = export_index.ptr(zcu); + switch (exp.opts.linkage) { + .strong => {}, + .weak, .internal, .link_once => continue, + } const gop = exports_by_name.getOrPutAssumeCapacity(exp.opts.name); if (gop.found_existing) { const existing_exp = gop.value_ptr.*.ptr(zcu); diff --git a/test/cases/export_override_libc.zig b/test/cases/export_override_libc.zig new file mode 100644 index 0000000000000000000000000000000000000000..bc16cb8dd2cdfcb0f09da2da83715b2ec9715321 --- /dev/null +++ b/test/cases/export_override_libc.zig @@ -0,0 +1,16 @@ +/// This implementation is intentionally incorrect so we can check that it is +/// called instead of the libc symbol. +export fn isdigit(c: c_int) c_int { + return @intFromBool(c == '0'); +} + +pub fn main() void { + const static = struct { + extern fn isdigit(c_int) c_int; + }; + if (static.isdigit('0') == 0) @panic("override failed: isdigit('0') == 0"); + if (static.isdigit('1') != 0) @panic("override failed: isdigit('1') != 0"); +} + +// run +// link_libc=true