From b2d8bcb7f1211a733fef47a2d179609324344991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=27vesim=27=20Kuli=C5=84ski?= Date: Sat, 6 Jul 2024 20:23:08 +0200 Subject: [PATCH 1/2] Export getauxval only when building executable --- lib/std/os/linux.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 3deac7a2f6ef..95cf3b3103c8 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -393,7 +393,9 @@ const extern_getauxval = switch (builtin.zig_backend) { }; comptime { - if (extern_getauxval) { + // Export this only when building executable, otherwis it is overriding + // the libc implementation + if (extern_getauxval and builtin.output_mode == .Exe) { @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); } } From 7d7ee0ac2a7c7703a3bf532e48fb6554bb84c9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=27vesim=27=20Kuli=C5=84ski?= Date: Sun, 7 Jul 2024 05:10:41 +0200 Subject: [PATCH 2/2] Export getauxval also when the root has main function --- lib/std/os/linux.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 95cf3b3103c8..c882ba8036fb 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -393,9 +393,10 @@ const extern_getauxval = switch (builtin.zig_backend) { }; comptime { - // Export this only when building executable, otherwis it is overriding + 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) { + if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) { @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); } }