I'm linking against a static library and I wonder how one should handle stripping of dead code in llvm/Clang. I can't find any documentation that hints that Clang has some equivalent of -Wl, --gc-section or -dead_strip.
I assume that some dead code elimination is performed automatically at the higher optimisation levels, but that's the case in gcc too, right? Yet, gcc provides some explicit control of this via the above mentioned flags. Does Clang not provide that or am I missing something?
(The system is OSX)
Dead stripping is a linker feature, not a compiler feature. Neither gcc nor clang have it, as a result. That's why you had to use -Wl
- you're passing that flag to the linker. The Mac OS X linker uses -dead_strip
. You can pass the flag directly to your clang invocation and it will pass it through automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With