
On the net you can find many descriptions of the mingw build and the GNU utilities under it. I also decided to write my own version, because firstly it is in Russian. Secondly, the latest stable sources are used (as of January 27, 2011). In the third,
loop optimization has been added (
graphite loop optimizations ). Fourthly, I describe the reasons for choosing one or another source configuration option. Fifth, not to forget.
Why collect mingw yourself?
- In order to configure the components as I need, and not the thousand users who download the standard package from the official site.
- So that I myself determine which components I need in the form of shared libraries with dll-kami, and which I link statically.
- To be sure that gcc works as efficiently as possible.
- To exclude possible bookmarks in executables.
- To better understand how GNU utilities are built and installed.
Anyone can find a reason for handwriting.
')
What is needed?
Oddly enough, but to build mingw you need mingw itself. Comrades tried and made a neat installation program, which itself will download and install the necessary packages. It lies on the
official site.In addition to mingw itself, during installation, select “C ++ Compiler” and “MinGW Developer ToolKit”. We put in C: \ MinGW.
Downloading source:
Optional:
Do not do without patience, perseverance and good luck!
Assembly
We create a working daddy C: \ mbuild on the fastest hard drive. All sources are added to C: \ mbuild \ distrib. We will grow mingw in C: \ mbuild \ release. Run the downloaded msys ...
cd / c / mbuild
A small note. Most of the instructions tell you to put the gmp, mpfr and mpc sources into a folder for gcc - it will compile them automatically. We will not do this because we are going to be screwed to gcc CLooP, but it depends on gmp. That is, we will have to build gmp before we proceed to the gcc configuration.
GMP
tar -xjf distrib / gmp-5.0.1.tar.bz2 && cd gmp-5.0.1
mkdir build && cd build
../configure --prefix = '/ c / mbuild / release' --enable-cxx --disable-static --enable-shared CPPFLAGS = '- fexceptions' &> config.my.log
make -j4 &> make.my.log
make install &> install.my.log
- --enable-cxx CPPFLAGS = '- fexceptions' - Required for correct ppl build
- --disable-static --enable-shared - In windows, you cannot have shared and static versions at the same time, otherwise the assembly of further components may fail. We will build the shared version. Do not worry, the dependencies are not transferred to programs compiled with mingw.
It is very important not to use the CFLAGS, CXXFLAGS and LDFLAGS optimization keys such as "-s -O2 -mtune = i686" - there were cases when ppl did not find gmp because of this.
Ppl
tar -xjf ../../distrib/ppl-0.11.tar.bz2 && cd ppl-0.11
mkdir build && cd build
../configure --prefix = '/ c / mbuild / release' --disable-static --enable-shared --disable-nls --enable-threads --disable-debugging --with-gmp-prefix = / c / mbuild / release --with-cflags = '- s -O2' --with-cxxflags = '- s -O2' &> config.my.log
make -j4 &> make.my.log
make install &> install.my.log
- --disable-static --enable-shared - which link option we chose for gmp should be the same for ppl.
- --disable-nls - disabling National Language Support will not require the application to communicate in Russian.
- --enable-threads - created by mingw, I will use to compile multi-threaded applications.
- --disable-debugging - debugging information to anything - it takes too much space.
- --with-gmp-prefix - tells you where to look for gmp.
- --with-cflags --with-cxxflags - some optimization.
During configuration, windows may indicate that the conftest program has not started. Do not panic - this is just the result of the work of the configure script.
CLooG / PPL
tar -zxf ../distrib/clog-ppl-0.15.10.tar.gz
cd cloog-ppl-0.15.10
mkdir build && cd build
../configure --prefix = '/ c / mbuild / release' --disable-static --enable-shared --with-ppl = / c / mbuild / release --with-gmp = / c / mbuild / release CFLAGS = '- s -O2' CPPFLAGS = '- s -O2' &> config.my.log
make &> make.my.log
There is an unpleasant part with configuration scripts. For some reason they simply do not. The make.my.log log indicates that the m4 folder is missing. I do not understand the reasons for her absence. Just copying it from ppl-0.11. Fortunately there are the necessary scripts.
make &> make.my.log
make install &> install.my.log
Options are clear from previous descriptions.
MPFR
tar -xjf distrib / mpfr-3.0.0.tar.bz2 && cd mpfr-3.0.0
mkdir build && cd build
../configure --prefix = '/ c / mbuild / release' --disable-static --enable-shared --enable-thread-safe --with-gmp = / c / mbuild / release CFLAGS = '- s -O2 'CPPFLAGS =' - s -O2 '&> config.my.log
make -j4 &> make.my.log
make install &> install.my.log
MPC
tar -xzf distrib / mpc-0.8.2.tar.gz
cd mpc-0.8.2
mkdir build && cd build
../configure --prefix = / c / mbuild / release --disable-static --enable-shared --with-gmp = / c / mbuild / release --with-mpfr = / c / mbuild / release CFLAGS = '-s -O2' CPPFLAGS = '- s -O2' &> config.my.log
make -j4 &> make.my.log
make install &> install.my.log
LIBICONV
tar -xzf distrib / libiconv-1.13.1.tar.gz && cd libiconv-1.13.1
mkdir build && cd build
../configure --prefix = / c / mbuild / release --enable-shared --disable-static --disable-nls CFLAGS = '- s -O2 -mno-cygwin' CPPFLAGS = '- s -O2 -mno -cygwin '&> confgi.my.log
make -j4 &> make.my.log
make install &> install.my.log
In general, libiconv is optional, but it is desirable to enable its support (very useful if you will be building other gnu utilities with this mingw).
- CFLAGS = '- mno-cygwin' In order for libiconv to compile correctly under msys, you should explicitly state that we are not using CygWin.
BINUTILS
tar -xjf distrib / binutils-2.21.tar.bz2 && cd binutils-2.21
mkdir build && cd build
../configure --prefix = / c / mbuild / release --disable-nls --enable-threads --with-gmp = / c / mbuild / release --with-mpc = / c / mbuild / release - with-mpfr = / c / mbuild / release - with-ppl = / c / mbuild / release - disabled-ppl-version-check - with-cloog = / c / mbuild / release - disabled-cloog-version -check CFLAGS = '- s -O2' CPPFLAGS = '- s -O2' &> config.my.log
make -j4 &> make.my.log
make install &> install.my.log
- --disable-ppl-version-check --disable-cloog-version-check Once I encountered the fact that the ppl version check scripts were looking for exactly version 10, and not higher, now I use these options by inertia, although in some places the situation already fixed. If you want, you can delve into the configure script by looking at the processing of ppl_version_minor. Binutils-2.21 is configured normally, but gcc-4.5.2 is not.
INCLUDE
Unpacking C: \ mbuild \ distrib \ w32api-3.14-mingw32-src.tar.lzma in C: \ mbuild \ w32api.
It is in w32api that
mingwrt can find it during assembly.
tar -xzf distrib / mingwrt-3.18-mingw32-src.tar.gz
cp -r w32api / include / c / mbuid / release
cp -r mingwrt-3.18-mingw32 / include / c / mbuild / release
To ensure that all dlls are correctly configured, add the release path to the PATH
export PATH = $ PATH: / c / mbuild / release
Gcc
tar -xjf gcc-4.5.2.tar.bz2
cd gcc-4.5.2
mkdir build && cd build
../configure --prefix = / c / mbuild / release --enable-shared = libstdc ++ --enable-threads --enable-version-specific-runtime-libs --enable-languages ​​= c, c ++ --with- dwarf2 --disable-sjlj-exceptions --disable-win32-registry --disable-werror --disable-nls --disable-multilib --with-gmp = / c / mbuild / release --with-ppl = / c / mbuild / release --disable-ppl-version-check --with-cloog = / c / mbuild / release --disable-cloog-version-check --with-mpfr = / c / mbuild / release --with- mpc = / c / mbuild / release --enable-libgomp --with-libiconv-prefix = / c / mbuild / release --enable-libstdcxx-debug --enable-cxx-flags = '- s -O2' - with-boot-ldflags = '- s' &> config.my.log
make -j4 BOOT_CFLAGS = '- s -O2' BOOT_CPPFLAGS = '- s -O2' &> make.my.log
The longest and most responsible part. I use the full source
gcc, and not separately gcc-core and gcc-c ++ because I include libgomp and zlib, but
they do not come with gcc-core.
- --enable-shared = libstdc ++ - I usually compile libraries statically, but sometimes I have to use stlport instead of native STL, so we will build it.
- --enable-version-specific-runtime-libs Affects the location of headers and runtime libraries. This option is needed in order to allow multiple versions of runtime libraries to be used with one mingw.
- --enable-languages ​​= c, c ++ - build the compiler for C and C ++ languages.
- --with-dwarf2 - debugging information dwarf-2
- --disable-sjlj-exceptions - disable sjlj exceptions
- --disable-win32-registry - it is fashionable to configure gcc so that it looks for information about the include folder in the windows registry. We are not interested.
- --disable-werror - werror is good when you manually specify it.
- --disable-nls this option does not affect the locale and everything related to wide characters in mingw. Their support will be incomplete (for example, retrieving the current user locale incorrectly - std :: locale ("") will always return locale ("C")) even if we enable NLS. This option affects only compiler messages. Personally, I would be unusual if he spoke in Russian ...
- --disable-multilib - we will use our compiler to create windows programs and only
- --enable-libstdcxx-debug This option allows, in addition to the basic version of the stdc ++ library, to have debugging so that you can travel through the library functions during debugging.
Unfortunately, with the debug information, not only the version that we connected with the --enable-libstdcxx-debug key is collected, but also the main one. I couldn’t overcome this with the gcc build options. Therefore, I suggest the following option:
cd i686-pc-mingw / libstdc ++ - v3
make -j4 CFLAGS = '- s -O2' CXXFLAGS = '- s -O2' &> make.my.log
Here we are somewhat cheated. In reality (including when collecting a cross-compiler) you have to build gcc yourself first using make all-gcc, then runtime and then complete the build of the whole gcc. The process is described, for example
here . But we will not bother, as in this particular case, everything works and so.
cd ../../
make install &> install.my.log
Unfortunately I never managed to compile gcc under mingw using profiling (make profiledbootstrap) - the process ended with errors. The most common segmentation fault of the compiler. And it's a pity ... they say a gain in compilation speed ~ 7%.
Runtime and W32API
w32api must be built with the new gcc. To do this, in the fstab file (by default, C: \ MinGW \ msys \ 1.0 \ etc \ fstab) change C: \ MinGW to C: \ mbuild \ release and launch the new msys. This instance of msys uses the newly collected gcc. But since we have not yet gotten rid of dependencies, we will have to tell msys where to look for the old mingw dlls:
export PATH = $ PATH: / c / MinGW / bin
W32api
cd ../../w32api
mkdir build && cd build
../configure --prefix = / c / mbuild / release CFLAGS = '- s -O2' CPPFLAGS = '- s -O2' &> config.my.log
make &> make.my.log
make install &> install.my.log
MingwRT
tar -xzf distrib / mingwrt-3.18-mingw32-src.tar.gz && cd mingwrt-3.18-mingw32-src
mkdir build && cd build
../configure --prefix = / c / mbuild / release CFLAGS = '- s -O2' CPPFLAGS = '- s -O2' &> config.my.log
make &> make.my.log
make install &> install.my.log
Due to the fact that gmp was not going to native gcc, it most likely has dependencies on libstdc ++. Dll and libgcc_s_dw2-1.dll. The first was collected with native gcc, the second will have to be copied from the old mingw. Alternatively, you can rebuild gmp in a new gcc to get rid of the swirl.
To reduce the size, you can safely delete unnecessary folders. For example share / doc.
Almost all. For comfortable work, we still need to build make.
MAKE
tar -xjf distrib / make-3.82.tar.bz2 && cd make-3.82
./configure --disable-nls --with-libiconv-prefix = '/ mingw' CFLAGS = '- s -O2' CPPFLAGS = '- s -O2' &> config.my.log
make -j4 &> make.my.log
cp make.exe /c/mbuild/release/bin/mingw32-make.exe
That's it. in daddy C: \ mbuild \ release got your neat mingw. Add packages to taste, wrap in a neat script and get something like
nuwen mingw . Successful builds!
Postscript: The mingw package we downloaded also contains:
- mingw32-autoconf
- mingw32-automake
- mingw32-autotools
- mingw32-basic-dsdtar
- mingw32-bzip2
- mingw32-cygutils
- mingw32-expat
- mingw32-gdb
- mingw32-gendef
- mingw32-gettext
- mingw32-libarchive
- mingw32-libtool
- mingw32-mingw-get
- mingw32-mingw-utils
- mingw32-package-list
- mingw32-pdcurses
- mingw32-pexports
- mingw32-popt
- mingw32-pthreads-w32
- mingw32-xz