magiclantern_simplified
magiclantern_simplified copied to clipboard
Find object file external functions that are never called, make them static
Just a guess, but I'm assuming we have a significant number of functions in C files that aren't marked static, when they could be.
Doing so would allow the compiler to better optimise, including removing the code from object files entirely if never called. This might be a useful size reduction in magiclantern.
Should be largely automatable with some combination of objdump and maybe semgrep to find usages.
Does it use -fdata-sections -ffunction-sections
and --gc-sections
to remove unused functions?
No idea, but I'm pretty sure it won't include object code for functions that are provably never called. However, if a function is non-static, because the symbol must be externally visible in object files, that function cannot be removed. The compiler cannot prove it's never called.
It marks sections, and the linker removes unused ones. So it removes unused functions, variables, etc. Static is a better idea probably.