## Table of Contents %TOC% Created from the original by [Jon Portnoy](http://cvs.gentoo.org/~avenj/), ## Introduction For a Linux to Hurd cross-compiler you need these versions (I tried newer versions of gcc but they won't compile) * [binutils-2.13.90.0.16](http://ftp.gnu.org/gnu/binutils/) * egcs-core-1.2.2 <- a very old version of gcc, but it is very stable, you will need it for compiling the gnumach headers and the mig kernel * [gcc-core-2.95.2](http://ftp.gnu.org/gnu/gcc/) <- for compiling hurd * [glibc-2.2.5](http://ftp.gnu.org/gnu/glibc/) * [gnumach-1.3](http://ftp.gnu.org/gnu/gnumach/gnumach-1.3.tar.gz) * [mig-1.3](http://ftp.gnu.org/gnu/mig/mig-1.3.tar.gz) * [hurd](http://www.gnu.org/software/hurd/download.html) ## Building ### The directory structure It is easier to compile the whole sources in an extra directory: * `build/binutils` <- the unpacked binutils sources * `build/binutils.build` * `build/egcs` <- the unpacked egcs sources * `build/egcs.build` * `build/gcc` <- the unpacked gcc sources * `build/gcc.build` * `build/glibc` <- the unpacked glibc sources * `build/glibc.build` * `build/gnumach` <- the unpacked gnumach kernel sources * `build/gnumach.build` * `build/mig` <- the unpacked mig kernel sources * `build/mig.build` * `build/hurd` <- the unpacked hurd kernel sources * `build/hurd.build` ### Exporting the `CFLAGS` and `PATH` `/usr/local` is where the sources we compile will be installed. If you want to choose another directory you have to change the path to the bin directory and too you have to change the `--prefix` path to the directory you want. $ export CFLAGS="-march=i686 -O2 -fomit-frame-pointer" $ export PATH=/usr/local/bin:$PATH **_All commands that are prefixed by `#` must be run as root with `CFLAGS` and `PATH` exported._** ### Cross binutils $ cd binutils.build $ ../binutils/configure --prefix=/usr/local --target=i686-pc-gnu $ make $ make check # make install $ cd .. ### Cross egcs When the `/usr/local/bin` directory do not exist before you will now have to export the `PATH` again because after installing binutils you will have it. $ cd egcs.build $ ../egcs/configure --prefix=/usr/local --target=i686-pc-gnu \ --with-gnu-as --with-gnu-ld $ make -k # make -k install $ ln -s /usr/local/i686-pc-gnu \ /usr/local/lib/gcc-lib/i686-pc-gnu/egcs-2.91.66/i686-pc-gnu $ cd .. ### GNUmach Headers $ cd gnumach.build $ ../gnumach/configure --build=i686-pc-linux-gnu --host=i686-pc-gnu # make -k install-headers prefix=/usr/local/i686-pc-gnu $ cd .. ### Mig Mig is the Mach Interface Generator - needed by Mach and the Hurd to create C code from their IDL files. Mig is what helps us do RPC without ever knowing much about it. $ cd mig.build $ ../mig/configure --target=i686-pc-gnu --host=i686-pc-linux-gnu \ --prefix=/usr/local $ make # make install $ cd .. ### Gnumach Headers inclusive Mig When you first compile the GNUmach headers Mig won't be mentioned (it wasn't installed actually) and this causes some errors when compiling the GNUmach headers but you need them to compile mig. (I don't know if you have to do this but i think it is the better way) $ cd gnumach.build $ rm -r * (deletes every file and directory in this directory) $ ../gnumach/configure --build=i686-pc-linux-gnu --host=i686-pc-gnu # make -k install-headers prefix=/usr/local/i686-pc-gnu $ cd .. ### Cross GCC For the coexistence of EGCS and GCC you have to move the `/usr/local/bin/i686-pc-gnu-gcc` to the `/usr/local/bin` directory in `i686-pc-gnu-egcs`. So you can choose wich compiler you want use: with the `CC` environment variable set to `i686-pc-gnu-egcs` you can use EGCS without this command you use GCC. # mv /usr/local/bin/i686-pc-gnu-gcc \ /usr/local/bin/i686-pc-gnu-egcs $ cd gcc.build $ ../gcc/configure --prefix=/usr/local --target=i686-pc-gnu \ --with-gnu-as --with-gnu-ld $ make -k compile the glibc-headers) # make -k install $ cd .. # ln -s /usr/local/i686-pc-gnu/ \ /usr/local/lib/gcc-lib/i686-pc-gnu/2.95.2/i686-pc-gnu You need `make -k` because otherwise it will fail but with `-k` you will have everything you need. ### Hurd Headers $ cd hurd.build $ ../hurd/configure --build=i686-pc-linux-gnu -�host=i686-pc-gnu \ -�prefix=/usr/local/i686-pc-gnu --disable-profile # make install-headers no_deps=t $ cd .. ### Cross GLibC For having glibc compiled with the cross-gcc and not with your original gcc you have to export another `PATH`. The normal user who configures and compiles and also root has to export this `PATH`. $ export PATH=/usr/local/bin:/usr/local/i686-pc-gnu/bin:$PATH $ cd glibc.build $ ../glibc/configure --without-cvs --enable-add-ons=crypt \ --disable-profile --build=i686-pc-linux-gnu \ --host=i686-pc-gnu --prefix=/usr/local/i686-pc-gnu AS ROOT WITH EXPORTED CFLAGS: # export PATH=/usr/local/bin:/usr/local/i686-pc-gnu/bin:$PATH # make -k install-headers install_root=/usr/local/i686-pc-gnu # cp ../glibc/include/features.h \ /usr/local/i686-pc-gnu/include/features.h # touch /usr/local/i686-pc-gnu/include/gnu/stubs.h $ cd .. ### Building Cross egcs # mv /usr/local/bin/i686-pc-gnu-gcc \ /usr/local/bin/i686-pc-gnu-foo (for protecting gcc) # mv /usr/local/bin/i686-pc-gnu-egcs \ /usr/local/bin/i686-pc-gnu-gcc $ cd egcs.build $ make # make install (as root, export CFLAGS and the NEW PATH) $ cd .. # mv /usr/local/bin/i686-pc-gnu-gcc \ /usr/local/bin/i686-pc-gnu-egcs # mv /usr/local/bin/i686-pc-gnu-foo \ /usr/local/bin/i686-pc-gnu-gcc ### Building Cross GCC $ cd gcc.build $ make # make install $ cd .. Remember to export `CFLAGS` and the new `PATH` ### Building Cross GLibC $ cd glibc.build $ make # make install root_install=/usr/local/i686-pc-gnu Remember to export `CFLAGS` and the new `PATH` For solving a glibc bug you have to link the `/usr/local/i686-pc-gnu/include/libc.so.0.2` with the `/usr/local/i686-pc-gnu/lib/libc.so` ever when you (re)install glibc. # ln -sf /usr/local/i686-pc-gnu/lib/libc.so.0.2 \ /usr/local/i686-pc-gnu/lib/libc.so ### Install the GNUmach kernel somewhere $ rm -r gnumach.build $ mkdir gnumach.build $ cd gnumach.build You will need more than the `-�target` and `-�host` variables to build the GNUmach kernel. You have to enable some kernel features with the `--enable` command to have your kernel working properly. To have a quick view of what you need you can view the `gnumach/i386/README-Drivers` (I do not know how old it is, so maybe there are more options available but i haven't searched for more). My configure command: $ ../gnumach/configure --build=i686-pc-linux-gnu \ --host=i686-pc-gnu �-enable-lpr \ --enable-floppy --enable-ide \ --enable-aic7xxx �-enable-rtl8139 # ln -s /usr/local/i686-pc-gnu/include \ /where/you/want/to/install/the/kernel/include # ln -s /usr/locali686-pc-gnu/lib \ /where/you/want/to/install/the/kernel/lib $ make # make install-kernel \ prefix=/where/you/want/to/install/the/kernel (as root ...) ### Hurd Servers $ rm -r hurd.build $ mkdir hurd.build $ cd hurd.build $ nano -w/vi (or what editor you ever use) ../hurd/Makeconf You have to comment out the `CFLAGS` in this file or delete the `-std=gnu99` and the `-O3`. $ ../hurd/configure �build=i686-pc-linux-gnu \ --host=i686-pc-gnu \ -�prefix=/where/you/want/to/install/the/kernel \ --disable-profile $ make -k # make -k install prefix=/where/you/want/to/install/the/kernel You have to use `-k` because when you don't use it the compilation will brake with an error. I tried different installations of gcc and glibc and too i used different versions of hurd but i cannot solve this prob so maybe it is hurd related. So there is no warranty that the hurd kernel you compiled will work. I will try it and then update this guide. ---- ## Document History Created from the original, , by [Jon Portnoy](http://cvs.gentoo.org/~avenj/) I would recommend not using EGCS, but instead using the GCC cross compiler. See [[Hurd/BuildingHurd]] and [[Mach/BuildingOskitMach]] for more information on building the GNU OS components.
-- [[Main/JoachimNilsson]] - 13 Apr 2003 Text formatting.
-- [[Main/OgnyanKulev]] - 13 Apr 2003