Re: cross compile gnumach and hurd
"Henning Riedel" <hriedel@HTWM.De> wrote Sat, 2 Dec 2000 03:48:05 +0100:
> Is there a way using that gcc-i386-gnu and the mig-stuff on other linux
> distributions than debian?
> I just have a SuSe 7.0 (or something between) and I just can find that
> deb-packages for the crosscompile stuff. I'm not really willing about
> installing another linux distribution in order to get that hurd running
> somehow.
Cross-compiling the Hurd is not hard. Beware that the instructions in
hurd/INSTALL-cross are out-of-date.
I was able to cross-compile the Hurd on FreeBSD (thanks to arkadi) after
a few tries. Attached is a summary of what had to be done. The main
difficulty with FreeBSD is that some utilities are not the GNU tools:
make != gmake, sed != gnu sed. This can cause some minor trouble to fix.
The biggest problem I encountered in installing a cross-compiled Hurd
from FreeBSD was, that mke2fs was not available there and e2fstools
contained too many Linux dependencies to be compilable on my box.
Strangely, FreeBSD can mount ext2 filesystems, but can't make 'em :-/
Since you're using a Linux box, you won't face this strange situation.
-Farid.
------ cut here ------- cut here -------- cut here -------- cut here --------
Cross-compiling the Hurd on a FreeBSD box
- - - - - - - - - - - - - - - - - - - - -
This is a summary of what I had to do to cross-compile the Hurd on a
FreeBSD box. Thanks to arkadi for helpful hints. Please send updates
or bug-fixes directly to me <farid.hajji@ob.kamp.net>. Thanks.
0. get [or update] from CVS gnumach, hurd, mig, glibc [and probably grub]
1. create a build directory structure like this:
build/
build/binutils -> $(SRC)/binutils-2.10/
build/binutils.build
build/gcc -> $(SRC)/gcc-2.95.2/
build/gccc.build
build/gnumach -> $(SRC)/gnumach/
build/gnumach.build
build/mig -> $(SRC)/mig/
build/mig.build
build/hurd -> $(SRC)/hurd/
build/hurd.build
2. get and install the following tools, if they are not already
prsent on your system:
gcc-2.95.2 native build-chain.
gawk-3.0.4
sed-3.02 GNU version of sed!
binutils-2.10 native build chain.
3. create cross-binutils:
make sure that binutils-2.10.tar.bz2 was unpacked in $(SRC)/binutils-2.10/
before resuming...
# set CFLAGS to this, so that no -g flag is used:
export CFLAGS="-march=i586 -O2 -fomit-frame-pointer"
# ensure that GNU sed is in the PATH before FreeBSD's sed:
export PATH=/usr/local/bin:$PATH
# configure binutils in the build.binutils directory,
# then build and install them.
cd build.binutils
../binutils/configure --prefix=/usr/local --target=i586-pc-gnu -v
gmake
gmake check
gmake install (as root, remember to set CFLAGS, PATH)
cd ..
4. start making gcc cross-compiler.
unpack gcc-core-2.95.2.tar.bz2 in $(SRC)/gcc-2.95.2/
then start first step of cross-compiler making...
cd build/gcc.build
../gcc/configure --prefix=/usr/local --target=i586-pc-gnu --with-gnu-as \
--with-gnu-ld
gmake -k
This will fail while trying to make libgcc2.a with the following symptoms:
-----------
In file included from tconfig.h:5,
from ../../gcc-2.95.2/gcc/libgcc2.c:33:
../../gcc-2.95.2/gcc/config/xm-gnu.h:31: fcntl.h: No such file or directory
../../gcc-2.95.2/gcc/libgcc2.c:41: stdlib.h: No such file or directory
../../gcc-2.95.2/gcc/libgcc2.c:42: unistd.h: No such file or directory
gmake[1]: *** [libgcc2.a] Error 1
/users/farid/build/gcc.build/gcc/xgcc -B/users/farid/build/gcc.build/gcc/ -B/usr/local/i586-pc-gnu/bin/ -I/usr/local/i586-pc-gnu/include -DCROSS_COMPILE -DIN_GCC -march=i586 -O2 -fomit-frame-pointer -I./include -c ../../gcc-2.95.2/gcc/libgcc1-test.c
../../gcc-2.95.2/gcc/libgcc1-test.c:101: warning: conflicting types for built-in function `memcpy'
----------
This error is _expected_ because the headers needed by the cross-compiler
are not yet installed. this is why we said -k in the make.
We'll return to finishing the cross gcc make later, when we have
installed the mach, hurd and glibc headers
(in /usr/local/i586-pc-gnu/include)
For now, just install some headers and stuff of gcc;
cd build/gcc.build
gmake -k install
ln -s /usr/local/i586-pc-gnu \
/usr/local/lib/gcc-lib/i586-pc-gnu/2.95.2/i586-pc-gnu
5. install mach headers
cd build/gnumach.build
../gnumach/configure --build=i386-unknown-freebsdelf --host=i586-pc-gnu
# become root, set CFLAGS and PATH...
gmake -k install-headers prefix=/usr/local/i586-pc-gnu
6. build mig
cd build/mig.build
../mig/configure --target=i586-pc-gnu --host=i386-unknown-freebsdelf \
--prefix=/usr/local
gmake
# as root:
cd /usr/local/i586-pc-gnu/include/mach
ln -s i386 machine
# as normal user:
gmake
gmake install (as root)
7. install hurd headers:
# first of all, generate a configure script from build/hurd/configure.in
cd build/hurd
autoconf
cd build/hurd.build
../hurd/configure --build=i386-unknown-freebsdelf --host=i586-pc-gnu \
--prefix=/usr/local/i586-pc-gnu --disable-profile
# as root (CFLAGS="-march=i586 -g"):
gmake install-headers no_deps=t
8. install glibc headers:
cd build/glibc.build
../glibc/configure --without-cvs --enable-add-ons=crypt \
--build=i586-unknown-freebsdelf --host=i586-pc-gnu \
--prefix= \
--disable-profile
# now install glibc headers:
# (as root):
gmake -k install-headers install_root=/usr/local/i586-pc-gnu
cp ../glibc/include/features.h /usr/local/i586-pc-gnu/include/features.h
mkdir /usr/local/i586-pc-gnu/include/gnu
touch /usr/local/i586-pc-gnu/include/gnu/stubs.h
9. let's finish building cross gcc, now that we have all headers we need:
cd build/gcc.build
export CFLAGS="-march=i586 -O2 -fomit-frame-pointer"
export C_INCLUDE_PATH=/usr/local/i586-pc-gnu/include
gmake
# as root:
gmake install
10. let's finish build of cross-glibc:
make sure, that at least here, gnu sed is in your PATH before
any other sed!!!
cd build/glibc.build
gmake <<< this takes a LONG time!
as root:
gmake install install_root=/usr/local/i586-pc-gnu
11. let's build gnumach now (from scratch):
erase and remake build.gnumach, then:
cd build/gnumach.build
../gnumach/configure --build=i386-unknown-freebsdelf --host=i586-pc-gnu \
--enable-floppy --enable-ide --enable-aic7xxx \
--enable-ul
# edit i386/Makefile: MAKE is set to make, not gmake! change this
# to reflect FreeBSD speciality. Then:
gmake << (lots of warnings can be ignored)
# this completes the build of gnumach kernel.
12. install gnumach kernel somewhere:
a. mkdir /gnu
b. ln -s /usr/local/i586-pc-gnu/include /gnu/include
ln -s /usr/local/i586-pc-gnu/lib /gnu/lib
alternatively: copy contents into /gnu/include, /gnu/lib,
but it's better to symlink right now, and copy from i586-pc-gnu
to /gnu/{include,lib} later.
c. as root in build/gnumach.build:
gmake install-kernel prefix=/gnu
13. fix a bug with libc symlinks: (do this _every_ time you make install
glibc, since libc.so is overwritten)
(as root:)
ln -s -f /usr/local/i586-pc-gnu/lib/libc.so.0.2 \
/usr/local/i586-pc-gnu/libc/libc.so
14. rebuild hurd from scratch:
rmdir build/hurd.build
mkdir build/hurd.build
cd build/hurd.build
# manually fix a bug in ../hurd/Makeconf:
# edit ../hurd/Makeconf: comment out definition of CFLAGS
# # CFLAGS=-Wall -g -O3
# remember: CFLAGS="-march=i586 -O2 -fomit-frame-pointer"
# if you want debug infos: -g -Winline (and probably -O)
# because of hurd_fail being inline...
../hurd/configure --build=i386-unknown-freebsdelf --host=i586-pc-gnu \
--prefix=/gnu --disable-profile
(ignore warning about ELF interpreter /lib/ld.so not found...)
gmake << takes a long time, ignore all warnings...
15. install hurd
(as root:)
export CFLAGS="-march=i586 -O2 -fomit-frame-pointer"
export PATH=/usr/local/bin:$PATH
export MAKE=/usr/local/bin/gmake
cd build/hurd.build
gmake install prefix=/gnu
cp ../hurd/debian/servers.boot /gnu/boot
16. cross-compile install bash and other stuff
to get a fully functional system,
mke2fs -O sparse_super -o hurd /dev/hdXXXX
mount this on newgnu and copy everything from /gnu to /newgnu...
then, native-install etc...
------ cut here ------- cut here -------- cut here -------- cut here --------
--
Farid Hajji -- Unix Systems and Network Admin | Phone: +49-2131-67-555
Broicherdorfstr. 83, D-41564 Kaarst, Germany | farid.hajji@ob.kamp.net
- - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - -
Murphy's Law fails only when you try to demonstrate it, and thus succeeds.
Reply to: