On Wed, 24 Apr 2019, Martin Storsjö wrote:
I tried bootstrapping a new separate install of gcc into a new sysroot all
within msys, in the same way as I bootstrap cross toolchains on linux. It
almost works, except for building some of the ADA tools. I tried just copying
in gnatmake/gnatbind/gnatlink from the existing msys environment though, and
that works, even if it is very ugly...
You can have a look at the full toolchain at
https://martin.st/temp/mingw-native.zip. My instructions/notes for how I
tried to build it are attached, and also available at
https://martin.st/temp/gcc-ucrt.txt in case the mailing list eats the
attachment. I haven't rerun/rechecked the instructions properly yet, but
they're just notes from what I'm trying to run while building this.
The gist of it is: Build new binutils and the host part of gcc into a new
sysroot. Install the mingw crt into the same sysroot. Build the runtime parts
of gcc using that same crt and install into the sysroot. Done.
All of this works splendidly, except for the ada parts, which I'm woefully
unfamiliar with.
With this toolchain, I'm able to do "gnatmake hello.adb", which produces a
hello.exe that links against the UCRT DLLs.
But like I said, the bin/gnatmake.exe, bin/gnatlink.exe and bin/gnatbind.exe
are just hacked around from my msys2 executables so far.
I tweaked the build a bit more and experimented further, and have
reproduced it a bit more. Now I'm able to build the ada tools as well.
The kind of single-stage non-bootstrap build I do requires having the same
version of gcc in the existing environment as I'm building though.
I've rebuilt a new toolchain available at
https://martin.st/temp/gcc-8.3-ada-ucrt.zip, and new updated instructions
at https://martin.st/temp/gcc-ucrt.txt (also attached for archival). The
new one is built with gcc 8.3 (even though the instructions mention 7.3).
// Martin
# In a msys2/mingw64 command prompt:
mkdir -p /c/code/gcc-bootstrap
cd /c/code/gcc-bootstrap
# Building the new gcc and its sysroot using the existing msys2/mingw64
# gcc installation:
# $ which gcc
# /mingw64/bin/gcc
# $ gcc --version
# gcc.exe (Rev2, Built by MSYS2 project) 7.3.0
export TOOLCHAIN_PREFIX=/c/code/mingw-native
export TARGET_TRIPLET=x86_64-w64-mingw32
# Build libraries that GCC needs. These can also potentially be found
# from the msys2/mingw64 installation, and that should probably also
# work just as well. If omitted, leave out the --with-gmp=$DEPENDS_PREFIX
# from the gcc configure command.
export DEPENDS_PREFIX=/c/code/gcc-depends
wget http://ftp.funet.fi/pub/gnu/gnu/gmp/gmp-6.1.2.tar.bz2
tar -jxvf gmp-6.1.2.tar.bz2
cd gmp-6.1.2
./configure --prefix=$DEPENDS_PREFIX --disable-shared
make -j$(nproc)
make install
cd ..
wget http://ftp.funet.fi/pub/gnu/gnu/mpfr/mpfr-4.0.2.tar.bz2
tar -jxvf mpfr-4.0.2.tar.bz2
cd mpfr-4.0.2
./configure --prefix=$DEPENDS_PREFIX --with-gmp=$DEPENDS_PREFIX --disable-shared
make -j$(nproc)
make install
cd ..
wget http://www.multiprecision.org/downloads/mpc-1.1.0.tar.gz
tar -zxvf mpc-1.1.0.tar.gz
cd mpc-1.1.0
./configure --prefix=$DEPENDS_PREFIX --with-gmp=$DEPENDS_PREFIX --disable-shared
make -j$(nproc)
make install
cd ..
# End of optional section.
wget http://ftp.funet.fi/pub/gnu/gnu/binutils/binutils-2.32.tar.bz2
tar -jxvf binutils-2.32.tar.bz2
cd binutils-2.32
mkdir build
cd build
../configure --prefix=$TOOLCHAIN_PREFIX --disable-werror --disable-multilib
make -j$(nproc)
make install-strip
cd ../..
# Clone mingw-w64; using a recent known-good version from the master branch.
# The v6.x branch should also probably be good for ucrt, but the master branch
# is certainly good at least.
git clone git://git.code.sf.net/p/mingw-w64/mingw-w64
cd mingw-w64
git checkout 69af6ee195e65a29acc02a49119a833606424a1b
cd mingw-w64-headers
mkdir build
cd build
../configure --prefix=$TOOLCHAIN_PREFIX/$TARGET_TRIPLET
--with-default-msvcrt=ucrt
make install
cd ../../..
# Build GCC; build the compiler itself and all tools, using the existing
# msys2/mingw64 compiler, having that compiler itself link against the
# CRT that it defaults to. This compiler will be set up that the code
# it produces uses UCRT though.
# Build the same version of gcc as in the surrounding host environment.
# This seems to be necessary for building the Ada tools this particular
# way (a single-stage, non-bootstrap build), as the Ada tools are built
# with the existing host Ada compiler, and the GCC Ada sources are picky
# about being built with the exact right version of the compiler.
wget http://ftp.funet.fi/pub/gnu/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.xz
tar -Jxvf gcc-7.3.0.tar.xz
cd gcc-7.3.0 && \
mkdir build
cd build
../configure --prefix=$TOOLCHAIN_PREFIX --enable-languages=c,c++,ada
--disable-multilib --with-gmp=$DEPENDS_PREFIX
--with-native-system-header-dir=$TOOLCHAIN_PREFIX/$TARGET_TRIPLET/include
--disable-bootstrap CXXFLAGS="-O2"
make -j$(nproc) all-gcc
make install-strip-gcc
cd ../..
# Now build the CRT runtimes using the newly built C/C++ compiler.
# Add the new toolchain/compiler to the PATH.
export PATH=$TOOLCHAIN_PREFIX/bin:$PATH
# $ which gcc
# /c/code/mingw-native/bin/gcc
# $ gcc --version
# gcc.exe (GCC) 7.3.0
cd mingw-w64/mingw-w64-crt
mkdir build
cd build
../configure --prefix=$TOOLCHAIN_PREFIX/$TARGET_TRIPLET --disable-lib32
--enable-lib64 --with-default-msvcrt=ucrt
make -j$(nproc)
make install
cd ../../..
# Build the libgcc/libstdc++ runtimes, with the new toolchain and its
# new sysroot (defaulting to UCRT).
cd gcc-7.3.0/build
make -j$(nproc) all-target
make install-target
# Build the rest of the gnat frontend tools using the old host ada compiler:
export PATH=/mingw64/bin:$PATH
make configure-gnattools
cd gnattools
make -j$(nproc) gnattools-cross
cd ..
make install-strip-gcc
cd ../../..
# Copy a few runtime dlls that the compiler ended up requiring.
cp /mingw64/bin/libiconv-2.dll $TOOLCHAIN_PREFIX/bin
cp /mingw64/bin/libwinpthread-1.dll $TOOLCHAIN_PREFIX/bin
cp /mingw64/bin/libgmp-10.dll $TOOLCHAIN_PREFIX/bin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public