GDC Cross-Compiler
From OSDev Wiki
| Difficulty level |
|---|
Beginner |
|
|
Contents |
Introduction
If you reached here, you should have enough knowledge about cross-compilers, how they work etc... Or if you don't, go check out our GCC Cross-Compiler article.
Requirements
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:
- GCC
- Make
- Flex
- Bison
If you plan to use GCC 4.3.0 or a later version, you will also have to install the following (using your system's package management):
If you plan to use GCC 4.5.0 or a later version, you will also have to install the following (using your system's package management):
- 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/. Make sure you downloaded exactly GCC ver 4.1.x (or 3.x, if you like old stuffs). Download them to /usr/src (or whereever you think appropriate), and unpack them. Also, we need gdc package from http://dgcc.sourceforge.net. Current version is 0.24
Preparation
export PREFIX=/usr/local/cross export TARGET=i586-elf cd /usr/src mkdir build build/binutils build/gcc
binutils
cd /usr/src/build/binutils /usr/src/binutils-x.xx/configure --target=$TARGET --prefix=$PREFIX --disable-nls make all make install
gcc
This needs some work out. First, unpack gcc, and we got /usr/src/gcc-x.x.x Go to /usr/src/gcc-x.x.x/gcc, and unpack gdc.This will create a subdirectory named "d".
cd /usr/src/gcc-x.x.x ./gcc/d/setup-gcc.sh
Then go to /usr/src/gcc-x.x.x/gcc/d, open d-lang.cc and look at line 188. You'll see this
const char* cygwin_d_os_versym = D_OS_VERSYM;
Change D_OS_VERSYM to whatever you want, since it is a string, like "MyOS". (Wilkie told me not to set it to NULL, it will make the compiler to segfault)
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
make all-gcc
make install-gcc
Step 2 -
TO BE CONTINUED...

