Instructions for building GDC with MinGW w64
These instructions are still being refined and will be released in script form when ready. At this moment, they are not for the faint of heart.
However, if you attempt it and run into any issues post a message on D.gnu.
These instructions create a 64-bit compiler with minimal user work. Suitable for testing purposes. I've made the effort of writing these directions from a clean install.
Obviously a 64-bit version of Windows is necessary. It is possible to use VirtualBox to get the proper environment.
For simplicity, the mingw-get installer was used. The new installer allows installation of the lastest MSYS and MDTK environment. mingw-get can be used instead but it is your responsibility to make sure all the dependencies and versions are met.
Install wget and unzip.
mingw-get install msys-wget mingw-get install msys-unzip
It is highly recommended to build inside an identity mount. A directory that resolves to the same using unix or windows notation. This can be set up by editing /etc/fstab in the msys environment.
Get GDC source code from Mercurial. Patches are attached to this ticket.
The following source versions were used:
# gcc-4.5.2-tdmsrc-1.zip : Contains useful patches and build options. # gcc-core-4.5.2.tar.bz2 : GCC. # gmp-4.3.2.tar.bz2 : Required by GCC. # mpc-0.8.2.tar.gz : Required by GCC. # mpfr-2.4.2.tar.bz2 : Required by GCC.
You can download the automatic installer, however I recommend downloading the individual packages:
Extract the compiler using tar --lzma -xvf <src> -C <tdm64 destination>. Once the compiler is extract you need to copy <tdm64 destination>/x86_64-w64-mingw32/lib32 to <tdm64 destination>/x86_64-w64-mingw32/lib/32/. This is required when building to allow GCC to find 32-bit libraries.
Extract GCC sources
Extract the GCC sources and apply the following patches from gcc-4.5.2-tdmsrc-1.zip.
- # gcc/dllinline.patch (this patch also contains chunks for G++, skip those chunks) # gcc/headerpath.patch # gcc/libgcceh.patch # gcc/libgomp.patch # gcc/libs64.patch (this patch also contains chunks for Fortran, ObjC and G++, skip those chunks) # gcc/lto-virtbase.patch # gcc/make-rel-pref.patch # gcc/relocate.patch
Extract GMP, MPFR and MPC into GCC.
Rename directories. This allows GCC to compile the libraries as part of the build process.
mv gmp-4.3.2 gmp mv mpfr-2.4.2 mpfr mv mpc-0.8.2 mpc
If you haven't already, start up a MSYS bash shell.
cd into the GDC source directory and run ./setup-gcc.sh <GCC_SRCDIR>
Set the path to the TDM64 compiler we extracted. This ensures that compiler is used above all others.
export PATH=<path to TDM64 directory>/bin:$PATH
Copied from the Makefile include in gcc-4.5.2-tdmsrc-1.zip
It is very important that --prefix and --with-local-prefix point to your TDM64 compiler directory. It will be used by the build process for system headers and libraries.
cd <GCC_SRCDIR> mkdir build cd build ../configure --build=x86_64-w64-mingw32 --enable-targets=all \ --enable-languages=c,d \ --enable-lto --enable-libstdcxx-debug \ --enable-version-specific-runtime-libs --enable-fully-dynamic-string \ --with-gnu-ld --disable-werror --disable-nls --disable-win32-registry \ --prefix=<TDM64 Compiler directory> --with-local-prefix=<TDM64 Compiler directory> \ --with-bugurl="https://bitbucket.org/goshawk/gdc/issues" --disable-bootstrap
make should work. To allow debugging, use make CFLAGS="-g3 -O0".
Before installing, edit the file build/gcc/d/d-confdefs.d. The first two lines are INCLUDE defines used by the compiler for relocation. Prefix 'C:'(case sensitive), if GDC was built inside an identity mount. Otherwise prefix the Windows path to the prefixed directory. This allows GDC to be relocated.
This is why I preferred manually extracting the compiler. If things mess up, it can be thrown away and replaced by a fresh directory.
make install prefix="<TDM64 Compiler Directory>"