INSTALLING 64-BIT AND 32-BIT GCC 10.3.0-2 EXECUTABLES THAT CAN COMPILE TO 64-BIT AND 32-BIT
MS WINDOWS CODE, RESPECTIVELY (MY FOLDER STRUCTURE).
------------
May 30, 2021 
------------

BUILD MINGW-64 GCC YOURSELF!
----------------------------
After having an on-line discussion with LHMouse from this thread, I was able to write
my own script to build gcc directly from the MinGW git repositories using MSYS2, and
I'm pretty excited about that--no more waiting for somebody to post a distribution.
Here is my latest build script if you want to try it yourself.  Be warned that on a pretty
fast system (core i9-9900 with SSD's), the build takes about 4 hours (2 hours for the 64-bit
exe's and 2 hours for the 32-bit exes).  It also requires several GB of disk space.  You'll
need my imerge.exe program to merge the two system include folders into one.
My favorite version of make.exe is included in this distro--admittedly it is antiquated:
make.exe and rsxnt.dll.

MSYS-2 repository:  repo.msys2.org/mingw/x86_64/
(You can check what the latest archived version of gcc is here.)

The build of gcc is a long process with multiple passes.  In each subsequent pass, the
compiler is re-built using the version that was just compiled.  Here is a summary
of what happens during the gcc build process.


                   ==  OR  ==


SKIP THE BUILD--JUST DOWNLOAD THE PRE-BUILT PACKAGE
---------------------------------------------------
You don't have to build your own if you just want to download my build directly.  My
goal is to have a minimalistic, straightforward folder structure that I use to compile
all my C/C++ code.  This distro also includes pthreads, ada, objective C, Fortran 95.

+-----------------------------------------------------------+
|   1. Download my gcc 10.3.0-2 distro (100 MB .7z file).   |
+-----------------------------------------------------------+

2. This package will extract to its own subfolder, mingw64_gcc10.3.0-2_willus.com, so I
   install from the root folder of D:\ like so:

        d:\mingw64_gcc10.3.0-2_willus.com
           +- include
           +- lib
              +- x64
              +- x32
           +- bin
              +- x64
              +- x32
              +- lib

3. 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

4. Script mingw.bat to set environment/path.  Usage:  mingw 64  or   mingw 32

    @echo off
    if not "%1"=="" goto envset
    echo "Usage:  mingw 32|64"
    goto end
    :envset
    set MINGW=d:\mingw64_gcc10.3.0-2_willus.com
    set MYINCLUDE=d:\my_include
    set MYLIB=d:\my_lib\mingw%1
    rem
    rem Remove all other C compilers from path.  You can remove the -u swithces
    rem if you are not using any other C compilers.  Change the drive letters to
    rem match your system
    rem
    repath -u c:\mingw* -u d:\mingw* -e %MINGW%\bin\x%1
    call _repath.bat
    del _repath.bat
    set c_include_dir=%MYINCLUDE%
    set c_include_path=%MYINCLUDE%;%MINGW%\include\x%1;%MINGW%\include;%MINGW%\include\ddk
    set cplus_include_path=%MYINCLUDE%;%MINGW%\include\x%1\c++;%MINGW%\include\c++;%MINGW%\include\c++\backward;%MINGW%\include\x%1;%MINGW%\include
    set library_path=%MYLIB%;%MINGW%\lib\x%1
    set libdir=
    set exedir=c:\bin%1
    set cc=gcc
    set cpp=g++
    set f77=gcc
    set cflags=-Ofast -m%1 -Wall
    gcc -v
    :end