Uh oh!
There was an error while loading. Please reload this page.
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| // 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 }); | ||
| } |
There was a problem hiding this comment.
Just for my edification, what's the technical reason for needing this @export?
There was a problem hiding this comment.
Honestly, I don't know. Maybe it can be removed in a different PR.
I'm not really easily able to learn much more about it right now because there hasn't been a new master build for download in over a week.
There was a problem hiding this comment.
I went digging through the history. The reason is that we only want a single getauxval implementation to be used at runtime (only the one that has elf_aux_maybe set from the start code is actually functional), so we're using weak linkage to accomplish that.
This is mainly relevant when linking multiple Zig compilation units together.
Fixes#21522
@rohlem's suggestion in #21522 to move the relevant comptime block into the container namespace used to define getauxval seems to work fine.
Before: 2016 bytes. After: 1944 bytes.
Might still not address all cases but I guess a new more specific issue can be opened for that.