GDC MINGW BUILD: version (Windows) NOT DEFINED

MINGW-USER MINGW at USER.UR
Mon Dec 24 02:21:19 UTC 2018


On Sunday, 23 December 2018 at 15:15:37 UTC, Johannes Pfau wrote:
> Am Sun, 23 Dec 2018 01:21:22 +0000 schrieb MINGW-USER:
>
>> It seems version (Windows) is not defined into the compiler 
>> gdc.exe gdc
>> (GCC) 9.0.0 20181221 (experimental)
>> built with msys2/mingw-w64 on Windows 10.
>> 
>> The trouble appears while building libdruntime
>> 
>> EXAMPLE: libphobos\libdruntime\core\stdc\time.d error: 
>> undefined
>> identifier 'time_t'
>> error: undefined identifier 'tm'
>> 
>> Manually add
>> 
>> version (GNU) {
>>      alias c_long time_t; alias c_long clock_t;
>> }
>> 
>> into time.d then it compiles but it seems weird.
>> 
>> The trouble is that there are many other similar errors with 
>> core\stdc\stddef.d, stdlib.d, stdint.d, etc ...
>> 
>> Help needed.
>
> That's an interesting coincidence, I just set up a Windows 10 
> VM + MSYS2 for MinGW development a day ago.
>
> How exactly did you build GCC? I tried to build in the mingw64 
> environment using the same configure flags as in the 
> mingw-w64-gcc package [1] and without any GCC patches. I had to 
> fix some build errors in filename.c, did you get these as well? 
> Additionally the built toolchain is not properly relocatable: 
> Installing into / works, but if I use DESTDIR=/somewhere/else 
> to install, the new gcc doesn't find the headers in 
> /mingw64/x86_64... anymore. So if you know any better way to 
> build GCC in the MSYS2 environment, please let me know :-)
>
> And regarding the specific problem you mentioned: As gdc is 
> untested on the mingw backend, the patches for mingw which set 
> version(Windows) have not been applied to the GCC sources. You 
> have to apply this patch manually: 
> https://github.com/D-Programming-GDC/GDC/blob/ 
> 958363de2ba09656de340d13ca56f80f8ba10805/patches/targetdm-untested.patch
>
> However, phobos probably won't build right now either way.
>
>
> [1]
> ../gcc-9-20181216/configure --enable-languages=lto,d,c++ 
> --prefix=/mingw64
> --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --
> host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 
> --with-native-system-
> header-dir=/mingw64/x86_64-w64-mingw32/include 
> --libexecdir=/mingw64/lib
> --with-arch=x86-64 --with-tune=generic --enable-shared 
> --enable-static --
> enable-libatomic --enable-threads=posix --enable-graphite 
> --disable-
> libstdcxx-pch --disable-libstdcxx-debug 
> --disable-isl-version-check --
> enable-lto --enable-libgomp --disable-multilib --disable-rpath 
> --disable-
> win32-registry --disable-nls --disable-werror --disable-symvers 
> --with-
> libiconv --with-system-zlib --with-gmp=/mingw64 
> --with-mpfr=/mingw64 --
> with-mpc=/mingw64 --with-isl=/mingw64 --with-gnu-as 
> --with-gnu-ld --
> disable-bootstrap --enable-libphobos


Yeah I had to fix some build errors in filename.c (attempt to use 
poisoned "malloc"; invalid const_cast from type 'const char*' to 
type 'void*'; and '_mkdir' was not declared in this scope)

The following script is based on the instructions I found at 
https://github.com/StephanTLavavej/mingw-distro

The end result will be stored at C:\build\dest
I can move/rename 'dest' to somewhere else and it works
(no relocatable problem, I guess)

I tried to reproduce every step I took. It's something like this 
...

------------- build mingw c, c++, d ------------------

Map C:\build to /build in msys2
(/etc/fstab.d)

export 
PATH="/c/Dev/mingw64/bin:/c/Dev/msys64/usr/bin:/c/Windows/System32:/c/Windows"
where /c/Dev/mingw64 is from 
https://sourceforge.net/projects/mingw-w64/files/Multilib%20Toolchains%28Targetting%20Win32%20and%20Win64%29/ray_linn/gcc-6.X-with-ada/gcc-6.1.0-multilib-mingw-4.0.6-with-ada-201605226.7z

Download binutils-2.31.1.tar.xz from the GNU FTP
and extract into /build

cd /build
mkdir build-binutils
cd build-binutils
../binutils-2.31.1/configure \
--build=x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
--target=x86_64-w64-mingw32 \
--prefix=/build/dest
make
make install


Download and extract mingw-w64-v5.0.4.zip from
https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
(version 6.0.0 does not work)

cd /build
mkdir build-mingw-w64
cd build-mingw-w64
../mingw-w64-v5.0.4/configure \
--build=x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
--prefix=/build/dest/x86_64-w64-mingw32 \
--disable-lib32 \
--with-libraries=winpthreads \
--with-tools=all
make
make install


Download and extract
- gmp-6.1.2.tar.gz
- mpfr-3.1.6.tar.gz
- mpc-1.1.0.tar.gz
- isl-0.18.tar.gz
into directory /build/gcc-all

Download 
https://github.com/StephanTLavavej/mingw-distro/blob/v15.4/mpfr.patch
patch -Z -d /build/gcc-all/mpfr-3.1.6 -p1 < mpfr.patch

cd /build/gcc-all
mv /path/to/gcc-trunk src
(where /path/to/gcc-trunk is the root directory of gcc svn)
mv gmp-6.1.2 src/gmp
mv mpfr-3.1.6 src/mpfr
mv mpc-1.1.0 src/mpc
mv isl-0.18 src/isl

Create junction point
cmd /C "mklink /J C:\build\dest\mingw 
C:\build\dest\x86_64-w64-mingw32"

cd /build
mkdir build-gcc
cd build-gcc
../gcc-all/src/configure \
--enable-languages=c,c++,d \
--build=x86_64-w64-mingw32 \
--host=x86_64-w64-mingw32 \
--target=x86_64-w64-mingw32 \
--disable-shared \
--disable-multilib \
--disable-bootstrap \
--prefix=/build/dest \
--with-sysroot=/build/dest \
--disable-libstdcxx-pch \
--disable-libstdcxx-verbose \
--disable-nls \
--disable-win32-registry \
--enable-threads=posix \
--enable-libgomp
make
make install

cp /build/dest/x86_64-w64-mingw32/bin/libwinpthread-1.dll 
/build/dest/bin/libwinpthread-1_x64.dll
cp /build/dest/x86_64-w64-mingw32/bin/libwinpthread-1.dll 
/build/dest/bin/libwinpthread-1.dll

Here I noticed libphobos is not built.

export 
PATH="/build/dest/bin:/c/Dev/msys64/usr/bin:/c/Windows/System32:/c/Windows"
cd /build
mkdir build-phobos
cd build-phobos
../gcc-all/src/libphobos/configure --prefix=/build/dest
make

Here I see the problem mentioned in the original post. I'll try 
to apply targetdm-untested.patch.

Thank you for the info.





More information about the D.gnu mailing list