First I want to mention, this is not a usable version of GDC. There is
a link issue with the phobos library and if you go through the effort of
compiling tango-0.99.8, you're bound to run into a couple other issues.
On the other hand, I don't know of anyone who is actively working with
GDC and windows so any help would be appreciated in bringing an up to
date GDC compiler to the platform.
GDC Issues
----------
There seem to be a couple issues with GDC, I want to investigate further
before writing bug reports.
* I believe GDC is not storing enough file information with the -g
option because GDB cannot find any source files.
* Template errors, can give the wrong file name when it fails to
instantiate a template.
Phobos Issues
-------------
Since I do not have any projects utilizing phobos, I can't test beyond
simple linking which fails with an undefined reference.
* undefined reference to 'libmsvcrt_a_iname'
Tango Issues
------------
The newest release 0.99.9 does not yet support GDC, 0.99.8 does not
support win32 & GDC. However it can be done and is not overly
difficult, but you will likely encounter the following issues.
* Variant with arrays fails with a template error. I believe it's
related to void initliaziers resetting type to void. char[] tmp = void;
declares tmp as void instead of char[].
* Throwing an exception inside a catch block causes the runtime to abort.
* I believe there may be an GC issue somewhere. I wrote a program to
try to understand D's garbage collection better, which would run
indefinately when compiled with an older version of GDC. Now it
segfaults after running about 10 seconds. It makes use of GC.addRoot
method to hold on to malloced memory.
Building an updated GDC on Windows
==================================
The procedures in this document are for setting up D 1.0 and have not
been used for D 2.0.
The build scripts included are modified from http://www.tdragon.net/recentgcc/
for gcc 4.3.1. pthreads and iconv support is not used.
All GMP & MPFR build scripts have options (c)onfigure (m)ake (i)nstall. The
GCC build script was slightly modified and has (c)onfigure (b)ootstrap (m)ake
(i)nstall. The first run should use (b) not (m) any changes made to the source
can use (m) after.
The following setup is required to build GCC 4.3.1 and GDC trunk for windows.
I recommned the automatic installers for simplicity and the automatic setup of
shortcuts and environment variables. Feel free to do it how you like.
Tools
* TDM GCC 4.4.1 :
http://sourceforge.net/projects/tdm-gcc/files/TDM-MinGW%20Installer/1.908.0/tdm-mingw-1.908.0-4.4.1-2.exe/download
* MSYS-1.0.11 :
http://sourceforge.net/projects/mingw/files/MSYS%20Base%20System/msys-1.0.11/MSYS-1.0.11.exe/download
* MSYS updates. Required for an out of memory issue within msys.
*
* Wget from GnuWin32 :
http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-bin.zip
* LibIntl : http://gnuwin32.sourceforge.net/downlinks/libintl-bin-zip.php
* OpenSSL required by wget :
http://downloads.sourceforge.net/gnuwin32/openssl-0.9.8h-1-bin.zip
Download the lastest gdc trunk.
hg clone http://bitbucket.org/goshawk/gdc/
Apply some patches for windows
------------------------------
At this time, these patches are not part of repository but are required to get
a working windows build.
cd gdc
wget http://bitbucket.org/m/attch/2010/02/fix_param_zu.patch
patch -p1 < fix_param_zu.patch
wget http://bitbucket.org/m/attch/2010/02/version_windows.patch
patch -p1 < fix_param_zu.patch
open d/dmd/root.c
goto line 595 and delete the duplicate case '/': statement
This is where binaries are stored.
mkdir /build
Compile GMP
--------------------
mkdir -p dev/build/gmp
cd dev
wget ftp://ftp.gmplib.org/pub/gmp-4.3.2/gmp-4.3.2.tar.bz2
tar xvjf gmp-4.3.2.tar.bz2
cd build/gmp
../../gmp-build.sh c m i
Compile MPFR
------------
cd ../..
wget http://www.mpfr.org/mpfr-current/mpfr-2.4.2.tar.bz2
tar xvjf mpfr-2.4.2.tar.bz2
mkdir build/mpfr
cd build/mpfr
../../mpfr-build.sh c m i
Compile GCC with c,d
--------------------
C++ should work, but adds a considerable amount of time to the build so I
ignored it for now. Ideally one would compile it too as a total replacement
for Mingw.
cd ../..
wget http://ftpmirror.gnu.org/gcc/gcc-4.3.1/gcc-4.3.1.tar.bz2
tar xvjf gcc-4.3.1.tar.bz2
cd gcc-4.3.1
cp -r ../../d gcc/d
./gcc/d/setup-gcc.sh --d-language-version=1
cd ..
mkdir build/gcc
cd build/gcc
../../gcc-build.sh c b i
Finishing the build environment
-------------------------------
If your brave enough to copy the newly compiled mingw over the installed one
go for it. Otherwise you'll have to download some extra files and extract
them the root directory of the gdc compiler.
Building Tango 0.99.8
---------------------
I haven't had time to test the newest version of Tango, partly because there
isn't much support for GDC as the last release was eons ago.
Win32 files tango/sys/win32
Other Issues
------------
Variant/Traits error with arrays. GDC has specific code for dealing with
static arrays that doesn't work
phobos std/c/windows/com.d extern(Windows) fails.
#!/bin/sh
GCC_SRC=../../gcc-4.3.1
PREFIX=/mingw
INSTALL_DIR=/build/gcc/b4.3.1-tdm-3/stage-sjlj
GMP_INSTALL=/build/win-gmp-install
MPFR_INSTALL=/build/win-mpfr-install
ICONV_INSTALL=/build/win-iconv-install
PTHREAD_INSTALL=/build/pthreads-w32-install
HOST=mingw32
TARGET=mingw32
BUILD=mingw32
export PATH=$PATH:/cygdev/gccbuild/libsfor43/pthreads-w32-install/bin
export
C_INCLUDE_PATH="$GMP_INSTALL/include;$MPFR_INSTALL/include;$ICONV_INSTALL/include;$PTHREAD_INSTALL/include"
export CPLUS_INCLUDE_PATH="$ICONV_INSTALL/include"
export
LIBRARY_PATH="$GMP_INSTALL/lib;$MPFR_INSTALL/lib;$ICONV_INSTALL/lib;$PTHREAD_INSTALL/lib"
if test "$1" = "c"
then
shift
VERSION=`hg tip | gawk '/changeset:(.*)/ { print $2 }'`
$GCC_SRC/configure --prefix="$PREFIX" \
--build=$BUILD \
--enable-languages=c,d \
--with-bugurl="http://www.tdragon.net/recentgcc/bugs.php" \
--disable-nls --disable-win32-registry \
--disable-werror --enable-threads --disable-symvers \
--enable-cxx-flags='-fno-function-sections -fno-data-sections' \
--enable-fully-dynamic-string \
--enable-version-specific-runtime-libs \
--enable-sjlj-exceptions \
--with-pkgversion="GDCCC TDM-1 for MinGW (gdc 1.045)" \
--with-gmp=$GMP_INSTALL --with-mpfr=$MPFR_INSTALL
if test "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "b"
then
shift
make CFLAGS="-O2 -D__USE_MINGW_ACCESS" \
BOOT_CFLAGS="-O2 -mtune=generic -D__USE_MINGW_ACCESS" \
CFLAGS_FOR_TARGET="-O2 -mtune=generic -D__USE_MINGW_ACCESS" \
CXXFLAGS="-mthreads -O2 -D__USE_MINGW_ACCESS" \
BOOT_CXXFLAGS="-mthreads -O2 -mtune=generic -D__USE_MINGW_ACCESS" \
CXXFLAGS_FOR_TARGET="-mthreads -O2 -mtune=generic -D__USE_MINGW_ACCESS" \
LDFLAGS="-s -Wl,--stack=0x2000000" BOOT_LDFLAGS=-s LDFLAGS_FOR_TARGET=-s \
bootstrap
if test "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "m"
then
shift
make CFLAGS="-O2 -D__USE_MINGW_ACCESS" \
BOOT_CFLAGS="-O2 -mtune=generic -D__USE_MINGW_ACCESS" \
CFLAGS_FOR_TARGET="-O2 -mtune=generic -D__USE_MINGW_ACCESS" \
CXXFLAGS="-mthreads -O2 -D__USE_MINGW_ACCESS" \
BOOT_CXXFLAGS="-mthreads -O2 -mtune=generic -D__USE_MINGW_ACCESS" \
CXXFLAGS_FOR_TARGET="-mthreads -O2 -mtune=generic -D__USE_MINGW_ACCESS" \
LDFLAGS="-s -Wl,--stack=0x2000000" BOOT_LDFLAGS=-s LDFLAGS_FOR_TARGET=-s
if test "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "i"
then
shift
rm -f gcc/cc1.exe gcc/cc1obj.exe gcc/cc1objplus.exe gcc/cc1plus.exe
gcc/f951.exe gcc/gnat1.exe
make DESTDIR="$INSTALL_DIR" LDFLAGS="-s -Wl,--stack=0x2000000" install
if test "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "t"
then
make check
fi
exit $?
#!/bin/sh
GMP_SRC=../../gmp-4.3.0
PREFIX=/build/win-gmp-install
BUILD=mingw32
if test "$1" = "c"
then
shift
$GMP_SRC/configure --prefix="$PREFIX" \
--build=$BUILD \
--enable-fat \
--enable-static \
CFLAGS="-O2 -mtune=generic"
if test "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "m"
then
shift
make
if test "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "i"
then
make install
fi
exit $?
#!/bin/sh
MPFR_SRC=../../mpfr-2.4.1
PREFIX=/build/win-mpfr-install
GMP_BUILD=/build/win-gmp-install
BUILD=mingw32
if test "$1" = "c"
then
shift
$MPFR_SRC/configure --prefix="$PREFIX" \
--build=$BUILD \
--with-gmp="$GMP_BUILD" \
CFLAGS="-O2 -mtune=generic"
if "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "m"
then
shift
make
if "$?" != "0"
then
exit $?
fi
fi
if test "$1" = "i"
then
make install
fi
exit $?