On 19/03/2023 13:38, 3119369616.qq via Gcc wrote:
To divide functions into sections and then remove unused sections, I
must provide flags "-fdata-sections" and "-ffunction-sections" in GCC
and a flag "--gc-sections" in LD. Most of the build systems don't
support these flags so GCC will generate bigger binaries. Is it
possible to enable this feature without  giving any command line
flags manually?

Just to be clear here - removing unused sections is only beneficial if you have a significant amount of unused code and data compiled in the build. That can sometimes be the case, if you are making re-usable library code. But for other types of code, it is better to be clear in the source code about what is and is not part of the program - i.e., if the function is not used by the program, it should not be in the source code. I don't know what kind of code you are working on, but it's worth considering.

Reply via email to