-
-
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
figure out why unused functions from builtin.a are not getting omitted from final binary #2062
Comments
It seems to happen only in release-safe and release-fast modes for me when compiling for In debug and release small modes, there are no calls to any compiler-rt functions that I can see. |
Note for webassembly what @shritesh found: #2248 (comment) |
I just pulled the latest zig and my freestanding arm project won't build anymore:
I think it is related to this issue. Also, unlike my previous comment, this error happens in all build modes. EDIT: nevermind, build issue... sorry for the noise |
I'm pretty sure that the problem is that all the different compiler_rt functions all end up in one object file (compiler_rt.o). In that case the linker has no option to link the complete object and thus end up with all the unnecessary code in the final executable. Instead to solve this problem all the different zig files in the compiler_rt should end up in a separate object file inside the libcompiler_rt.a This way the linker can choose the correct object file. I found this by doing Edit: I'm gonna try to make a PR for this, if I get a confirmation that this is the actual problem. I'm quite sure tho. |
@andrewrk I would like to solve this, because it's pretty annoying when build stuff for small embedded microcontrollers. However, I'm not sure if I should implement |
I would try |
Landed in 372b615. Thanks @FireFox317! Hello World on Linux is now 6 KB after being stripped of debug info:
|
I'm pretty sure when I solved #54 it was working but now if I do this:
That's not supposed to be in there.
sqrt
(among others) isn't called from this application.On the other hand functions from compiler_rt.a are correctly getting omitted.
Maybe we should do
-ffunction-sections
?The text was updated successfully, but these errors were encountered: