On Mon, 1 Apr 2019, Kacvinsky, Tom wrote:

Hi,

I think the important distinction here is to make between building the
compiler itself (which is a binary which you build using your existing 
toolchain,
using the CRT that is default/usable there), and building the runtimes (libgcc,
libstdc++, libada) which the compiler will be using later.

The compiler itself can't be built linking to UCRT (which is what you are doing
in effect, even though you are linking to the old plain msvcrt.dll, and the
libgcc/libstdc++ you'll be linking also is for msvcrt.dll), but you only want to
build the runtimes (libgcc, libstdc++, libada) that way.

In my own setup for bootstrapping a mingw cross compiler on linux, I do the
following:

- Build binutils with --target=<arch>-w64-mingw32 --prefix=<prefix>
- Install mingw-w64-headers with --prefix=<prefix>/<arch>-w64-mingw32
- Build the compiler part of gcc with --target=<arch>-w64-mingw32
   --prefix=<prefix> --enable-languges=c,c++, but only compile the compiler
   itself (by "make all-gcc; make install-gcc")
- Build the mingw-w64-crt with --prefix=<prefix>/<arch>-w64-mingw32
   --host=<arch>-w64-mingw32
- Build the rest of gcc with "make; make install" in the gcc directory

I don't know if the gcc configure script has got a special place to inject extra
flags only for building the runtimes.

But setting up the newly installed mingw headers and crt with --with-default-
msvcrt= (especially if you are installing this into a separate sysroot different
from your existing compiler) should at least work, since the build of the
runtimes should end up using those headers.

Or maybe gcc has got a way of setting them separately from the flags for the
compiler itself?

OK, I built GCC as follows:

./configure --prefix=/mingw64 --enable-languages=c,c++,ada 
--build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 
--target=x86_64-w64-mingw32 --disable-multiarch   
--with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include

make all-gcc
make install-gcc

Then I built the MinGW-w64 CRT as follows

./configure --prefix=/mingw64/x86_64-w64-mingw32 --build=x86_64-w64-mingw32 
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multiarch  
--with-default-msvcrt=ucrt --disable-lib32 --with-libraries=all

make
make install

Then I went back to the GCC directory and ran
make

This failed.  IT for some reason wanted to go back to stage-1, and the 
--disable-multiarch is no longer in effect - it tried to build a 32-bit libgcc, 
which failed because it could find a 32-bit libkernel.a.  I don't want 32-bit 
support at this time.

I guess the problem is that you are trying to overwrite the current mingw installation, which presumably is in /mingw64/x86_64-w64-mingw32.

Did you install the headers also? you need to install crt and headers in sync.

When updating the files in /mingw64, which were already used for building the compiler itself, you trigger rebuilding of it because files used in the build have been updated. That's my guess of what's happening.

You probably need to do the gcc/mingw bootstrap into a different directory than the one you are using for building gcc itself, and then finally swap /mingw64 and the new mingw/gcc installation in the end. I do appreciate that this is a bit tricky if you have other files in there (installed by msys2) that you want brought along as well.

As for dual x86_64/i686 multiarch builds, unfortunately I don't know how to do them. I've only done both separately.

// Martin



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to