Closed th-otto closed 5 months ago
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:
Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker create larger object and executable files and are also slower. These options affect code generation. They prevent optimizations by the compiler and assembler using relative locations inside a translation unit since the locations are unknown until link time. An example of such an optimization is relaxing calls to short call instructions.
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.
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.
@hifi could you comment on if we still need these compiler options at all?