Clone wiki

gdc / MinGW64

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.

Quick Build

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.

Source code

Get GDC source code from Mercurial. Patches are attached to this ticket.

The following source versions were used:

  1. : Contains useful patches and build options.
  2. gcc-core-4.5.2.tar.bz2 : GCC.
  3. gmp-4.3.2.tar.bz2 : Required by GCC.
  4. mpc-0.8.2.tar.gz : Required by GCC.
  5. mpfr-2.4.2.tar.bz2 : Required by GCC.

TDM64 Compiler

You can download the automatic installer, however I recommend downloading the individual packages:

  1. binutils-2.21-tdm64-1.tar.lzma
  2. mingw64-runtime
  3. gcc-4.5.2-tdm64-1-c++.tar.lzma
  4. gcc-4.5.2-tdm64-1-core.tar.lzma

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

  1. gcc/dllinline.patch (this patch also contains chunks for G++, skip those chunks)
  2. gcc/headerpath.patch
  3. gcc/libgcceh.patch
  4. gcc/libgomp.patch
  5. gcc/libs64.patch (this patch also contains chunks for Fortran, ObjC and G++, skip those chunks)
  6. gcc/lto-virtbase.patch
  7. gcc/make-rel-pref.patch
  8. 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

Setup GDC

Copy the D folder into <GCC_SRCDIR>/gcc or, if your Windows version supports this, using a Windows Adminstrative Command Shell cd into <GCC_SRCDIR>/gcc and issue mklink /D d <relative path to d directory>. This will create a symbolic link so that any chnages to the D sources is reflected automatically.

If you haven't already, start up a MSYS bash shell.

From the top-level GCC directory, run gcc/d/ <options>


Setting PATH

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

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.

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="" --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>"