It's not really a chicken and egg situation.  You just need to
convince GCC to be a cross-compiler hosted on the mingw-msvcrt
environment and targeting the mingw-ucrt environment.  Any libraries
you build targeting ucrt (including mingw-w64's) would go in a
directory like /mingw64-ucrt instead of /mingw64 to avoid confusion.
When you build executables that are part of GCC, they would link to
the UCRT.

But that seems like an uncommon configuration and GCC might not
understand it.  I did a quick search for "ucrt" in the GCC 8.3.0
source code and I don't see anything about it except in libsanitizer.
I'm not sure if you can somehow add "ucrt" to the triple that GCC uses
to identify the system it's targeting (x86_64-w64-mingw32).  There
might be a lot of code in GCC that assumes that all MinGW environments
are equal if their architectures are equal, so it might be hard to
convince GCC that it is a cross-compiler.  That makes me think it
might actually be easier if the cross-compiler where hosted in the
msys2/Cygwin runtime, or on Linux.

Here's a project I made to make it easy to cross-compile for MinGW on Linux:

https://github.com/DavidEGrayson/nixcrpkgs

It has no support the UCRT, but since its scripts are small and
simple, it might be easy to add it.  (Right now it only takes 362
lines of scripts and 8 patches to build a cross-compiling toolchain
with binutils, GCC 8, and mingw-w64.)

--David

On Thu, Apr 18, 2019 at 7:04 AM Kacvinsky, Tom <[email protected]> wrote:
>
>
>
> > -----Original Message-----
> > From: Kacvinsky, Tom <[email protected]>
> > Sent: Wednesday, April 17, 2019 12:39 PM
> > To: [email protected]
> > Subject: Re: [Mingw-w64-public] PKGBUILD script for toolchain, still having
> > GCC compile errors
>
> <snip/>
>
> >
> > This is good stuff, thanks for the instructions.  One question, though.  I 
> > want
> > mingw-w64-crt v6.0.0 support for UCRT>  How did I modify the PKGBUILD
> > script to get this support?  While I am at it, I want winpthreads support 
> > and
> > perhaps she instead of sjlj exception handling for libgnat.
>
> So I thought I'd change the configure options in PKGBUILD for the CRT to add
>
> --with-default-msvcrt=ucrt
>
> built and installed it.  But now when building GCC, I get the following
>
> C:/msys64-redux/mingw64/lib/gcc/x86_64-w64-mingw32/8.3.0/adalib/libgnat.a(argv.o):(.rdata$.refptr.__imp__environ[.refptr.__imp__environ]+0x0):
>  undefined reference to `__imp__environ'
> collect2.exe: error: ld returned 1 exit status
> gnatlink: error when calling C:\msys64-redux\mingw64\bin\gcc.exe
> gnatmake: *** link failed.
>
> This is not surprising since the GCC I have on the system contains a libgnat 
> that
> uses the older MSVC runtime, which requires the _environ symbol.  So I have a
> chicken and egg situation here.
>
> Any way around this?
>
> Thanks,
>
> Tom
>
> _______________________________________________
> Mingw-w64-public mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


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

Reply via email to