INSTALLING 64-BIT AND 32-BIT GCC 4.8.3 EXECUTABLES THAT CAN COMPILE TO 64-BIT AND 32-BIT CODE, RESPECTIVELY (MY FOLDER STRUCTURE). To do this install, I install two of the mingw-64 automated builds under one folder and then make some slight adjustments to them. The combined distribution takes up about 800 MiB of disk space. May 23, 2014 ------------ 1. Download these two distros: a. i686-4.8.3-release-win32-sjlj-rt_v3-rev0.7z b. x86_64-4.8.3-release-win32-sjlj-rt_v3-rev0.7z (available from http://sourceforge.net/projects/mingw-w64) 2. Extract the two distros under a root folder like "d:\mingw" and re-name the roots to "x64" and "x32" like below (this is just my personal preference): d:\mingw +- x64 (re-named from \mingw64) +- include (from \mingw64\include and \mingw64\x86_64-w64-mingw32\include) +- libexec (from \mingw64\libexec) +- lib (from \mingw64\lib and \mingw64\x86_64-w64-mingw32\lib) +- bin (from \mingw64\bin) +- x32 (re-named from \mingw32) +- include (from \mingw32\include and \mingw32\i686-w64-mingw32\include) +- libexec (from \mingw32\libexec) +- lib (from \mingw32\lib and \mingw32\i686-w64-mingw32\lib) +- bin (from \mingw32\bin) 3. Remove these folders (I never use them): \mingw64\opt \mingw64\licenses \mingw64\share \mingw64\etc \mingw32\opt \mingw32\licenses \mingw32\share \mingw32\etc 4. Move these files: a. Everything in \mingw\x64\x86_64-w64-mingw32\include to \mingw\x64\include b. Everything in \mingw\x64\x86_64-w64-mingw32\lib to \mingw\x64\lib c. Everything in \mingw\x64\include\c++\x86_64-w64-mingw32\bits to \mingw\x64\include\c++\bits d. Everything in \mingw\x64\include\c++\x86_64-w64-mingw32\ext to \mingw\x64\include\c++\ext e. Everything in the \mingw\x32\i686-w64-mingw32\include folder to \mingw\x32\include f. Everything in the \mingw\x32\i686-w64-mingw32\lib folder to \mingw\x32\lib g. Everything in \mingw\x32\include\c++\i686-w64-mingw32\bits to \mingw\x32\include\c++\bits h. Everything in \mingw\x32\include\c++\i686-w64-mingw32\ext to \mingw\x32\include\c++\ext 5. After step 4, remove \mingw\x64\x86_64-w64-mingw32 and \mingw\x32\i686-w64-mingw32 (Don't need the lib32 or lib64 folders and don't need the bin folder.) You can also remove \mingw\x32\include\c++\i686-w64-mingw32 and \mingw\x64\include\c++\x86_64-w64-mingw32 6. Edit \mingw\x64\include\float.h and \mingw\x32\include\float.h and add these lines to both (I insert them after the line that says #define LDBL_MIN __LDBL_MIN__): /* The difference between 1 and the least value greater than 1 that is representable in the given floating point type, b**1-p. */ #undef FLT_EPSILON #undef DBL_EPSILON #undef LDBL_EPSILON #define FLT_EPSILON __FLT_EPSILON__ #define DBL_EPSILON __DBL_EPSILON__ #define LDBL_EPSILON __LDBL_EPSILON__ 6. (Optional) Create subfolder "dontuse" in the lib dirs (\mingw\x64\lib and \mingw\i386\lib) and move *dll* to these subfolders. I do this so that I avoid unexpected DLL dependencies. 7. Add make.exe and rsxnt.dll to d:\mingw\i386\bin and d:\mingw\x64\bin since I like them. 8. Optimizations a. One-pass max: -Ofast -flto -fomit-frame-pointer -momit-leaf-frame-pointer -fgraphite-identity -floop-interchange -floop-block -floop-parallelize-all -ftree-loop-distribution -ftree-parallelize-loops=2 -pthread -m64 -Wall b. Profile generate: -Ofast -flto -fomit-frame-pointer -momit-leaf-frame-pointer -fgraphite-identity -floop-interchange -floop-block -pthread -floop-parallelize-all -ftree-parallelize-loops=4 -ftree-loop-distribution -march=native -m64 -Wall -fprofile-generate=d:\gcc_profiles c. Profile use: -Ofast -flto -fomit-frame-pointer -momit-leaf-frame-pointer -fgraphite-identity -floop-interchange -floop-block -pthread -floop-parallelize-all -ftree-parallelize-loops=4 -ftree-loop-distribution -march=native -m64 -Wall -fprofile-use=d:\gcc_profiles 9. Scripts to set environment/path: a. 64-bit: @echo off call goclear.bat (removes all other compiler dirs from path) call _repath.bat del _repath.bat repath -u c:\mingw* -e d:\mingw\x64\bin repath -e d:\mingw\x64\bin call _repath.bat del _repath.bat set c_include_path=d:\my_include;d:\mingw\x64\include set cplus_include_path=d:\my_include;d:\mingw\x64\include;d:\mingw\x64\include\c++;d:\mingw\x64\include\c++\backward set library_path=d:\my_libs\mingw64;d:\mingw\x64\lib set cflags=-Ofast -m64 -Wall gcc -v b. 32-bit: @echo off call goclear.bat (removes all other compiler dirs from path) call _repath.bat del _repath.bat repath -u c:\mingw* -e d:\mingw\x32\bin call _repath.bat del _repath.bat set c_include_path=d:\my_include;d:\mingw\x32\include set cplus_include_path=d:\my_include;d:\mingw\x32\include;d:\mingw\x32\include\c++;d:\mingw\x32\in clude\c++\backward set library_path=d:\my_libs\mingw32;d:\mingw\x32\lib set cflags=-Ofast -m32 -Wall gcc -v