-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linux: omit getauxval from binary if not needed #22276
base: master
Are you sure you want to change the base?
Conversation
lib/std/start.zig
Outdated
// This must be done after PIE relocations have been applied or we may crash | ||
// while trying to access the global variable (happens on MIPS at least). | ||
std.os.linux.elf_aux_maybe = auxv; | ||
if (!std.os.linux.extern_getauxval) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now realize that this check would essentially have to be "if std.os.linux.getauxval was analyzed" or is potentially going to be called somewhere. That makes this a lot harder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be done through an std option. Not doing this for now so just ignore this.
7cac9bc
to
9304f54
Compare
198253f
to
2f994d9
Compare
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for my edification, what's the technical reason for needing this @export
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.