zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 263ba346198c921cf80e63db0c45405dba029933 (tree)
parent 27c1f2b3a04960d9e8701f420560cc53e8e5f1dd
Author: wooster0 <wooster0@proton.me>
Date:   Fri, 20 Dec 2024 14:14:38 +0900

linux: don't export getauxval when not required

Diffstat:
Mlib/std/os/linux.zig | 18+++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig @@ -482,22 +482,22 @@ pub const O = switch (native_arch) { /// Set by startup code, used by `getauxval`. pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; +/// Whether an external or internal getauxval implementation is used. const extern_getauxval = switch (builtin.zig_backend) { // Calling extern functions is not yet supported with these backends .stage2_aarch64, .stage2_arm, .stage2_riscv64, .stage2_sparc64 => false, else => !builtin.link_libc, }; -comptime { - 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 }); - } -} - pub const getauxval = if (extern_getauxval) struct { + comptime { + const root = @import("root"); + // Export this only when building an executable, otherwise it is overriding + // the libc implementation + if (builtin.output_mode == .Exe or @hasDecl(root, "main")) { + @export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak }); + } + } extern fn getauxval(index: usize) usize; }.getauxval else getauxvalImpl;