S390x cross compiler
How to boot strap a gcc cross compiler on linux.zsuse$ lib/rpm> ./config.guess s390x-ibm-linux
Create the directory structure
ukgccc$ mkdir crossbuild
Extract the toolchain
ukgccc$ bunzip2 -c gcc-3.4.4.tar.bz2|tar xf - ukgccc$ bunzip2 -c binutils-2.16.tar.bz2 |tar xf - ukgccc$ bunzip2 -c linux-2.6.9.tar.bz2 |tar xf - ukgccc$ bunzip2 -c gdb-6.3.tar.bz2|tar xf - ukgccc$ bunzip2 -c glibc-2.3.tar.bz2|tar xf -
ukgccc$ mkdir build-binutils build-gcc build-glibc build-gdb
Set the environment to reduce typing
ukgccc$ export TARGET=s390x-ibm-linux ukgccc$ export PREFIX=/usr/local/crossgcc ukgccc$ export TARGET_PREFIX=$PREFIX/$TARGET ukgccc$ export PATH=$PATH:$PREFIX/bin
Create the kernel headers and copy them
ukgccc$ cd linux-2.6.9 ukgccc$ make ARCH=i386 CROSS_COMPILE=s390x-ibm- menuconfig ukgccc$ cp -r include/linux $TARGET_PREFIX/include ukgccc$ cp -r include/asm-s390x $TARGET_PREFIX/include/asm ukgccc$ cp -r include/asm-generic $TARGET_PREFIX/include/
Create the binutils for s390x (assembler linker etc)
ukgccc$ cd build-binutils ukgccc$ ../binutils-2.16/configure --target=$TARGET \ --prefix=$PREFIX --disable-nls -v ukgccc$ make all
Create the gcc cross compiler for s390x (without threads to start with)
ukgccc$ cd build-gcc ukgccc$ ../gcc-3.4.4/configure --target=$TARGET --prefix=$PREFIX \ --without-headers --with-newlib --disable-threads -v ukgccc$ make all-gcc ukgccc$ make install-gcc
Create GLIBC for s390x
ukgccc$ CC=${TARGET}-gcc ../glibc-2.3/configure --target=$TARGET \
--prefix=$PREFIX --with-headers=${TARGET_PREFIX}/include
ukgccc$ make all
ukgccc$ make install_root=${TARGET_PREFIX} prefix="" install
Compile the final GCC!!
ukgccc$ cd build-gcc ukgccc$ rm -rf * ukgccc$ ../gcc-3.3.2/configure --enable-languages=c \ --target=$TARGET --prefix=$PREFIX ukgccc$ make all ukgccc$ make install
Cross compiler BootStrapped to compile executables for s390 architecture
ukgccc$ vi hello.c #includemain() { for(;;) { printf ("Hello World!\n"); } } ukgccc$ s390-unknown-linux-gnu-gcc hello.c -o hello ukgccc$ file hello hello: ELF 32-bit MSB executable, IBM S/390, version 1 (SYSV), for GNU/Linux 2.4 .3, dynamically linked (uses shared libs), not stripped zsuse$ ./hello Hello World! localhost g1sda1 # s390x-unknown-linux-gnu-gcc hello.c -o hello64 localhost g1sda1 # file hello64 hello64: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), not stripped
