If you reached here, you should have enough knowledge about cross-compilers, how they work. and so on. If you don't, check out GCC Cross-Compiler.
We assume you have a host system with a working GCC installation. If you are not using a bash shell, you might have to modify some of the command lines below. If you have just installed the basic Cygwin package, you have to run the setup.exe again and install the following packages:
You will also have to install the following (using your system's package management):
- GNU GMP (libgmp-devel on Cygwin, libgmp3-dev on apt-based systems, dev-libs/gmp on Gentoo)
- GNU MPFR (libmpfr-devel on Cygwin, libmpfr-dev on apt-based systems, dev-libs/mpfr on Gentoo)
- MPC (libmpc-devel on Cygwin, libmpc-dev on apt-based systems, dev-libs/mpc on Gentoo)
Step 1 - Bootstrap
We will build a toolset running on your host that can turn source code into object files for your target system.
We need the binutils and the GCC packages from http://ftp.gnu.org/gnu/. As of 2018-08-17, GCC 8.2.0 works. Download them to /usr/src (or where ever you think appropriate), and unpack them. Also, you need to get the gdc-8-stable branch at https://github.com/D-Programming-GDC/GDC/tree/gdc-8
export PREFIX=/usr/local/cross export TARGET=i586-elf cd /usr/src mkdir build build/binutils build/gcc
cd /usr/src/build/binutils /usr/src/binutils-x.xx/configure --target=$TARGET --prefix=$PREFIX --disable-nls make all make install
First, unpack gcc, and we got /usr/src/gcc-x.x.x Then, from the GDC repo, run this:
Ensure that you used the gdc-8-stable
Now, you can build GCC.
cd /usr/src/build-gcc export PATH=$PATH:$PREFIX/bin ../gcc-x.x.x/configure --target=$TARGET --prefix=$PREFIX --disable-nls \ --enable-languages=c,d,c++ --without-headers --disable-libphobos make all-gcc make install-gcc
Step 2 - D runtime
The D frontend version 2.079.0 has complete support for the runtime in a pay-you-go fashion. The current gdc-8 branch uses frontend version 2.068.0 or similar. A pull request has been setup, however.
Till then, you can copy object.d from any `/import` directory from any other installation and remove out the `extern(C)` references, testing as you go. Remove everything that you can. TypeInfo, Throwable, Exception, etc. are required by the compiler (for now). You can also copy the standard library from other D OS projects (search on GitHub).