On Wed, 27 Mar 2019, Kacvinsky, Tom wrote:
It's not missing because it's deprecated or something of that effect. It's
missing because ucrtbase.dll doesn't export any symbol named _environ.
If you build code that reference the _environ variable with headers set to
__MSVCRT_VERSION__ >= 0x1400, "_environ" will expand to (*
__p__environ()).
I decided to get off my butt and rebuild GCC (in particular the Ada compiler).
I am using MSYS2 with MinGW-w64 6.0.0. Downloaded the GCC 8.3.0 source
code and unpacked it.
Ran configure as follows:
CFLAGS="-D__MSVCRT_VERSION__=0x1400" CPPFLAGS="-D__MSVCRT_VERSION__=0x1400"
CXXFLAGS="-D__MSVCRT_VERSION__=0x1400" ./configure --prefix=/home/vapkay/gcc-8.3.0
--enable-languages=c,c++,ada --host=x86_64-w64-mingw32
The -D I added is to force the Ada runtime to not contain a reference to
__imp__environ,
but to use what's above.
I must be doing something wrong yet again because I keep running into errors,
such
as the following
.libs/lto-plugin.o:lto-plugin.c:(.text+0x4a): undefined reference to
`__stdio_common_vsscanf'
So if anyone has any hints as how to best build GCC for MinGE-w64, I would like
that guidance.
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?
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public