📜 ⬆️ ⬇️

Build Mingw in Windows do it yourself

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?




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



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


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


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


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.

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:

Source: https://habr.com/ru/post/112673/


All Articles