If compiling with GCC or linking with ld.bfd, these options have little
effect, but if built with Clang and linked with LLD, they provide a
quite notable size decrease - this shrinks an entire llvm-mingw
distribution package by 22%.
If building with BUILD_SHARED_LIBS with LLD, this requires a version
of LLD that contains a fix for auto exporting symbols from comdats,
2b01a417d7ccb001ccc1185ef5fdc967c9fac8d7.
@mati865, do you use such builds in MSYS2, and will this be an issue
for you, if you'd upgrade to LLVM 13 and build it with LLVM/LLD 12?
(Then again, you can set LLVM_NO_DEAD_STRIP on the first build to
get an initial build of LLVM 13.)
To the best of my knowledge, MSVC users typically get these features by default in release builds. Consider that cl /O2 enables /Gy or function sections. From there it's just a matter of passing /OPT:REF to the linker, and I think cmake does, although I don't have a minute to check right now.