-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
lib/std/os/linux.zig
Outdated
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"))) { |
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 think the extern_getauxval and
in this if
should be superfluous, because it's already implied by the if (extern_getauxval)
around the containing struct
.
If that branch isn't taken, the compiler should never analyze this comptime
block inside of it.
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.
Good point
198253f
to
2f994d9
Compare
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.