How to build GNU cross-compilers

From HW wiki
Jump to navigation Jump to search

Toolchain preparation and kernel build information

by Pavel Píša

Debian PowerPC GCC build log

Debian GCC-4.3 build logs

Kernel headers install

mkdir src
cd src
git clone git://
mkdir -p build/{arm,powerpc,i386,x86_64}/linux
cd build/powerpc/linux

Copy and adapt File:How to build GNU cross-compilers-GNUmakefile.txt to override ARCH and select kernel source directory


make headers_install

The header-files for building GCC nd GLIB are prepared in usr/include directory. Copy files found there to the directory /usr/powerpc-linux-gnu/sys-include


The required files are glibc-2.7ds1.tar.bz2 glibc-linuxthreads-20071023.tar.bz2 glibc-libidn-2.7.tar.bz2 glibc-ports-2.7.tar.bz2

mkdir -p src
cd src
tar -xjf ../glibc-2.7ds1.tar.bz2
tar -xjf ../glibc-linuxthreads-20071023.tar.bz2
tar -xjf ../glibc-libidn-2.7.tar.bz2
( cd glibc-2.7 ; mv glibc-libidn-2.7 libidn )
tar -xjf ../glibc-ports-2.7.tar.bz2
( cd glibc-2.7 ; mv glibc-ports-2.7 ports )
ln -s glibc-2.7 glibc

Prepare directory to build PowerPC version of GLIBC

mkdir -p build/powerpc-linux/glibc

If there is no previous install of GLIBC, use next dummy build to install headers. They are required to build GCC later

libc_cv_ppc_machine=yes \
libc_cv_mabi_ibmlongdouble=yes \
libc_cv_mlong_double_128=yes \
libc_cv_forced_unwind=yes \
libc_cv_c_cleanup=yes \
CC=gcc \
../../../src/glibc/configure --prefix=/usr \
       --build=x86_64-linux-gnu \
       --host=powerpc-linux-gnu \
       --prefix=/usr \
       --without-cvs \
       --enable-add-ons=libidn,nptl \
       --enable-profile \
       --without-selinux \
       --with-headers=/usr/powerpc-linux-gnu/sys-include \
       --enable-kernel=2.6.26 \
       --enable-hacker-mode \
       --without-cvs --disable-sanity-checks
make DESTDIR=/usr-pkg/glibc-linux-powerpc-2.7-1 \
      inst_includedir=/usr-pkg/glibc-linux-powerpc-2.7-1/include \

Build binutils

../../../binutils/configure \
       --prefix=/usr \
       --disable-nls \
       --build=x86_64-linux-gnu \
       --host=x86_64-linux-gnu \
       --target=powerpc-linux-gnu \
make && make DESTDIR=/usr-pkg/binutils-powerpc-linux-gnu_2.18-2_amd64 install

Build GCC

../../../gcc-4.3/configure -v \
        --enable-languages=c,c++ \
        --prefix=/usr \
        --enable-shared \
        --with-system-zlib \
        --without-included-gettext \
        --enable-threads=posix \
        --disable-nls \
        --enable-clocale=gnu \
        --enable-libstdcxx-debug \
        --enable-objc-gc \
        --enable-mpfr \
        --enable-softfloat \
        --enable-tls \
        --enable-secureplt \
        --enable-targets=powerpc-linux,powerpc64-linux \
        --with-cpu=default32 \
        --with-long-double-128 \
        --enable-checking=release \
        --build=x86_64-linux-gnu \
        --host=x86_64-linux-gnu \
        --target=powerpc-linux-gnu \
        --enable-version-specific-runtime-libs \
        --disable-libgomp \

Finally build GLIBC

../../../src/glibc/configure \
       --build=x86_64-linux-gnu \
       --host=powerpc-linux-gnu \
       --prefix=/usr \
       --without-cvs \
       --enable-add-ons=libidn,nptl \
       --enable-profile \
       --without-selinux \
       --with-headers=/usr/powerpc-linux-gnu/sys-include \
make install_root=/usr-pkg/glibc-2.7-powerpc install

Bare (xxx-elf) and RTEMS builds with NewLib

Download latest or matching NewLib from

tar -xzf newlib-2.0.0.tar.gz
cd gcc-4.8.1
ln -s ../newlib-2.0.0/newlib

When configuring GCC, use

configure --with-newlib ...

More detailed instructions for RTEMS toolchain preparation can be found at