Skip to content

Commit 263ba34

Browse files
wooster0alexrp
authored andcommitted
linux: don't export getauxval when not required
1 parent 27c1f2b commit 263ba34

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/std/os/linux.zig

+9-9
Original file line numberDiff line numberDiff line change
@@ -482,22 +482,22 @@ pub const O = switch (native_arch) {
482482
/// Set by startup code, used by `getauxval`.
483483
pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
484484

485+
/// Whether an external or internal getauxval implementation is used.
485486
const extern_getauxval = switch (builtin.zig_backend) {
486487
// Calling extern functions is not yet supported with these backends
487488
.stage2_aarch64, .stage2_arm, .stage2_riscv64, .stage2_sparc64 => false,
488489
else => !builtin.link_libc,
489490
};
490491

491-
comptime {
492-
const root = @import("root");
493-
// Export this only when building executable, otherwise it is overriding
494-
// the libc implementation
495-
if (extern_getauxval and (builtin.output_mode == .Exe or @hasDecl(root, "main"))) {
496-
@export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
497-
}
498-
}
499-
500492
pub const getauxval = if (extern_getauxval) struct {
493+
comptime {
494+
const root = @import("root");
495+
// Export this only when building an executable, otherwise it is overriding
496+
// the libc implementation
497+
if (builtin.output_mode == .Exe or @hasDecl(root, "main")) {
498+
@export(&getauxvalImpl, .{ .name = "getauxval", .linkage = .weak });
499+
}
500+
}
501501
extern fn getauxval(index: usize) usize;
502502
}.getauxval else getauxvalImpl;
503503

0 commit comments

Comments
 (0)