-
Notifications
You must be signed in to change notification settings - Fork 55
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
Add check whether compiler supports -fdata-sections/-ffunction-sections #979
Conversation
@hifi could you comment on if we still need these compiler options at all? |
It would be an optimization to reduce the executable size, but imho only makes sense when used in conjunction with --gc-sections when linking. For MiNT (where all libraries are statically linked) that makes a difference of ~1K |
I think those weren't for optimizing but to allow calls to non-existent functions that were optimized out later - this was when we were working on the early version of the code. We probably don't want those if the code compiles without on the CI. |
Please remove those flags. According to GCC documentation:
hence this is generally a bad idea. If we want to remove dead global functions we should use LTO instead. |
It makes a difference of ~100k of the executable size in my case. LTO does not help, it does not remove unused functions, and it can't be used with static libraries, since they may be compiled by a different compiler version. But i have no problem cancelling this PR, i can arrange also to add those flags in my build script. |
interesting. Passing -fwhole-program helps? Also, can you compare the symbols with and without fdata-sections ffunction-sections so we have a list of funcions that are removed during the link process? |
A log file of the linker about the discarded sections is attached. |
I am approving this since there is no other way in the GNU toolchain to remove those symbols without resorting to LTO, which currently breaks the game. |
I'll merge this as is and maybe look at if the game still compiles without those on linux with GCC. |
No description provided.