When libstdc++ is used, even though I did not use any iostream related functions, the final binaries still have iostream and locale related symbols, making the binaries unreasonably large (> 2.7MB without -s, ~700KB with -s). -flto -fno-rtti -fno-exceptions -fdata-sections -Os did not help. Visual Studio 2017 RC2 stripped them away without requiring any optimization flags!
I want to emphasize the difference in size:
30/12/2016 10:38 AM 272,384 cl-ios.exe
30/12/2016 10:38 AM 133,120 cl-stk.exe
30/12/2016 10:38 AM 133,120 cl-str.exe
30/12/2016 10:38 AM 132,096 cl-vec.exe
30/12/2016 10:38 AM 3,009,831 gcc-ios.exe
30/12/2016 10:38 AM 2,724,773 gcc-stk.exe
30/12/2016 10:38 AM 2,721,771 gcc-str.exe
30/12/2016 10:38 AM 547,632 gcc-vec.exe
See http://stackoverflow.com/questions/40856787/gcc-strip-unused-functions and http://stackoverflow.com/questions/41371324/gcc-configure-option-explanations for my failed attempts to solve this problems.
See attachment for repro.
gcc spec
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.3.0/lto-w
rapper.exe
Target: x86_64-w64-mingw32
Configured with: ../configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw
32 --target=x86_64-w64-mingw32 --prefix=/c/mingw64 --with-sysroot=/c/mingw64 --w
ith-gmp=/c/mingw64/gmp --with-mpfr=/c/mingw64/mpfr --with-mpc=/c/mingw64/mpc --d
isable-nls --disable-multilib --disable-libstdcxx-pch --disable-shared --disable
-win32-registry --disable-libstdcxx-debug --disable-libstdcxx-verbose --with-tun
e=haswell --enable-lto --enable-checking=release --enable-languages=c,c++ --enab
le-libstdcxx-time --enable-threads=win32 --enable-libatomic --enable-fully-dynam
ic-string
Thread model: win32
gcc version 6.3.0 (GCC)
If this is not the right place to file the bug, please help/guide me to file it to the correct place.