Build Instructions
Required source packages
- A recent GCC 3.3.x release or 3.4 snapshot. The C++ package
is also required.
- The gdc package from the main page.
Required software
- The usual GCC
requirements
- An already-installed C++ compiler (if you use make bootstrap, the new g++
will not be used). G++ 3.x is known to work. G++ 2.x is
known to not work.
Directories
- <srcdir>
-- Location of the GCC sources
- <builddir>
-- Build directory for GCC
- <prefix>
-- Install directory for GCC
Building the Compiler and Runtime Library
- Unpack the GCC archive. This creates <srcdir>.
- Change to the <srcdir>/gcc directory.
- Unpack the DMD-GCC glue archive. This will create a
subdirectory named "d".
- Change back to <srcdir> and run the setup script:
./gcc/d/setup-gcc.sh
On Darwin, this will ask if you want to apply additional patches.
Unless you are cross-compiling to another target, answer "yes".
- Build GCC using the normal install
instructions. The
only difference is that "d"
is added to the --enable-languages
option. Unless you will not be using the recls package, you also
need to enable the C++ compiler.
If you need to specify a compiler
to build GCC other than the
system's default, use the "CC"
and "CXX" environment
variables. Example:
CC=gcc3 CXX=g++3 <srcdir>/configure
--prefix=/usr/local/gcc-3.4 --enable-languages=c,d,c++
Remember to always use "gmake"
if GNU Make is not the system's default.
IMPORTANT: If you are
updating from an earlier version of GDC without doing a fresh build,
delete all object files in <builddir>/gcc/d before building.
- Install normally with "make
install".
Building a Cross Compiler
(This section is not complete)
Building a cross compiler takes some extra effort now (except for
MinGW.) It will become more automated as people contribute
information for various targets.
You will need to create two files (three for a unix target) that are
normally generated during a native build. The files are frag-gen,
frag-math, and (for unix) frag-unix. Here are some ways to create
the files:
- Do a native build and see what is required. The files will
be in <builddir>/<target>/libphobos.
- Look at the existing files in <srcdir>/gcc/d/phobos/config/mingw.
- Once you have a C cross-compiler, just compile gen_config1.c,
gen_math.c, gen_unix.c, run them on the target, and copy the files back
to your build system.
Once you have the files, put them in a directory and configure with the
option --enable-phobos-config-dir=<dir>.
Runtime Library Notes
- To run the unit tests, rebuild Phobos with "-funittest" in the DFLAGS and then run "make check-target-libphobos".
(TODO: allow setting DFLAGS from the configure command.)
- On Darwin and FreeBSD, some std.math tests will fail because
there
is no 80-bit real (or library support for it.)
- On FreeBSD and Linux, the test of the "%A" format will fail due
to a library bug.
- If you use recls, you need to add -lstdc++ to the link
flags (or run g++ and add
-lphobos and -lpthread.) Also add <prefix>/lib
to LD_LIBRARY_PATH or
whatever is necessary for your system to find shared libraries. OR
build GCC and your programs with a static libstdc++.