I've read all the internet and try many solutions but nothing worked for me. I have gcc 4.5.2 (specially this version, because newer versions of gcc add a lot of unnecessary when compiling, and the file size will grow significantly).
So gcc -v:
C:\MinGW\bin>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
Target: mingw32
Configured with: ../gcc-4.5.2/configure --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --disable-werror --build=mingw32 --prefix=/mingw
Thread model: win32
gcc version 4.5.2 (GCC)
So question: How to change this confire on windows? (I have msys, I think I need it for changing config with './configure') For example I want to write '--disable-libgomp'. How can I make this?
PS: maybe it will be usefull, I build my program with 'gcc -o prog.exe prog.cpp prog.o -s -Os -lole32 -luuid -lshlwapi -lcomctl32 -mwindows -lstdc++' (60Kb with gcc 4.8.1 and 20Kb with gcc 4.5.2).
UPDATE
This is the perfect solution of "How build GCC"
My configure flags:
./configure --enable-languages=c,c++ --disable-static --enable-shared --disable-sjlj-exceptions --disable-libgcj --disable-bootstrap --disable-libstdcxx-pch --disable-libgomp --with-dwarf2 --disable-win32-registry --disable-libstdcxx-debug --disable-concept-checks --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw --with-gmp=c:/mingw/src/gmp --with-mpfr=c:/mingw/src/mpfr --with-mpc=c:/mingw/src/mpc --with-libelf=c:/mingw/src/libelf
or with other flags you need.
Don't forget to mount with MSYS: mount PATH_TO_MINGW /mingw like
mount c:/mingw /mingw
You will run into some errors, but they are very simple to correct.
Good luck!