[PATCH] D101568: [cmake] Use -ffunction-sections and -Wl,--gc-sections on MinGW targets

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 23:57:45 PDT 2021


mstorsjo added a comment.

In D101568#2727411 <https://reviews.llvm.org/D101568#2727411>, @mati865 wrote:

> I have observed size reduction in another project using GCC+Binutils so it's a bit surprising to me.

Hmm, ok, that's odd. A user tried different combinations of this in https://github.com/lovell/sharp-libvips/pull/88#issuecomment-791326495 and saw only a size increase with those options with GCC+binutils, and I tried building LLVM (statically linked only) and compared one binary where I know -ffunction-sections -Wl,--gc-sections have got a big imapct (llvm-cvtres shrinks from ~5 MB to ~500 KB). I tried GCC+LLD, GCC+binutils, Clang+binutils and Clang+LLD, and I only saw the size decrease in the Clang+LLD configuration.

> We don't use `BUILD_SHARED_LIBS` but we do use `LLVM_BUILD_LLVM_DYLIB` and `LLVM_LINK_LLVM_DYLIB` if it matters.
> I don't think this will be an issue, `gc-sections` fix seems important enough to backport it even on its own.

Ah, right. FWIW I tested building with `LLVM_LINK_LLVM_DYLIB` and that configuration does break with -ffunction-sections -Wl,--gc-sections unless you have the fixed version of the linker. But you're right that the gains are big enough that it's worth working around that if needed, instead of delaying it by 1 release.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101568/new/

https://reviews.llvm.org/D101568



More information about the llvm-commits mailing list