-
-
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
-fstrip removes exported symbols when building executable #22339
Comments
You probably want |
I'm not an expert in low level and assembly output generation
This gives the smaller size version of the executable |
Well, what exactly is your goal? It normally doesn't make a ton of sense to export a function from an executable, which is why you have to opt into it with |
Thanks for the explanation. I get that exporting functions from an executable isn’t a common thing and that using -rdynamic is the intentional way to opt into it. Still, the increase in size from -rdynamic feels a bit off, especially since small binary sizes is one of Zig selling point. In cases where you really need to export just one or two functions, it feels like the current approach punishes that use case by adding unnecessary bloat. I get that -fstrip is doing what it’s supposed to, but the trade-off here feels a little inconvenient when the goal is keeping the binary lean while still exporting something essential. I get it if this is just how it’s designed to work, but it feels like a tricky spot for people in this specific situation. |
To be clear, we only advertise small binary sizes for The good news, though, is that if you use |
what does |
It links libc. |
Summary
When using the
-fstrip
flag withzig build-exe
, the exported symbols are removed from the resulting binary, which seems unexpected.Steps to Reproduce
main.zig
with the following content:foo
function in the resulting binary:Observed Behavior
Output
The
foo
section is not found, indicating that the-fstrip
flag removed the exported symbol.Expected Behavior
The
foo
function, being explicitly marked asexport
, should remain accessible in the binary, even when-fstrip
is usedEnvironment
Additional Note
If this behavior is intentional, clarification in the documentation would be helpful. If not, this might be a bug with
-fstrip
implementation.The text was updated successfully, but these errors were encountered: