Closed rongjiecomputer closed 7 years ago
Forgot to post my 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)
I'm confused as to what change you're requesting from me here.
I found out what happens now: it is due to --disable-libstdcxx-verbose
, this disables verbose messages for unhandled exceptions and also saves a lot of space.
Example:
int main() {
throw 5;
}
With --disable-libstdcxx-verbose
, program will abort silently the usual message like this:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
Otherwise it will show extra message:
terminate called after throwing an instance of 'int'
If users really need this verbose message for debugging, they can do this:
#include <exception>
#include <stdexcept>
int main() {
std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
throw 5;
}
Thanks, I'll think about it.
Note to self: read https://gcc.gnu.org/onlinedocs/libstdc++/manual/configure.html
Based on your build scripts, I managed to create my own gcc and binutils just to see what other customization you can try as well.
I found out that the sizes of executables produced by my toolchain and yours are different, though execution time is more or less the same.
Without
-s
and so on, my toolchain always produces larger executables, probably because I did not use-s
when I built Mingw-w64 runtime and gcc's libraries. With-s -ffunction-sections -Wl,--gc-sections
, there is no difference in size.With
-s -ffunction-sections -Wl,--gc-sections
, my toolchain produces executable about half the size than yours.Attached size.zip for you to test it in your machine. (Github does not support .7z)
Note:
-march=native
is used to optimize the code for the current machine.-ffunction-sections -Wl,--gc-sections
is used to strip unused function symbols, but this feature is still experimental for COFF/PE format, performs better for ELF format (Linux/Mac). Use-ffunction-sections
alone will cause object file to become larger.