From e5c974fa5cd3f9ed49463b597954a053da91de6d Mon Sep 17 00:00:00 2001 From: Vesim Date: Mon, 15 Jul 2024 14:48:40 +0200 Subject: [PATCH] std.os.linux: export getauxval only when building executable or root has main function --- lib/std/os/linux.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 43abbcc1a9..a5d90c5cc3 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -393,7 +393,10 @@ const extern_getauxval = switch (builtin.zig_backend) { }; comptime { - if (extern_getauxval) { + const root = @import("root"); + // Export this only when building executable, otherwise it is overriding + // the libc implementation + if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) { @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); } }