Skip to content
Baptiste Wicht edited this page Sep 3, 2016 · 18 revisions

This page explains how to build the cross compiler for building and running Thor.

Download

Download binutils and GCC

mkdir $HOME/src/
cd $HOME/src/
wget ftp://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.gz
wget ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.3/gcc-4.9.3.tar.gz
tar xvzf binutils*
tar xvzf gcc*

Configuration

export CC=gcc
export CXX=g++
export LD=ld.bfd
export PREFIX="$HOME/opt/cross"
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

Build binutils

cd $HOME/src
mkdir build-binutils
cd build-binutils
../binutils-*/configure --target=$TARGET --prefix="$PREFIX" --disable-nls
make
make install

Build GCC

cd $HOME/src
mkdir build-gcc
cd build-gcc
../gcc-*/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --enable-languages=c,c++
make all-gcc
make all-target-libgcc CFLAGS_FOR_TARGET="-mcmodel=large"
make install-gcc
make install-target-libgcc

Normally, you should now have a working x86_64-elf cross compiler.

On Gentoo

On Gentoo, it should be easier to create a cross-compilation chain and especially easier to have multiple cross compilation chains.

sudo emerge crossdev
sudo mkdir -p /usr/local/portage-crossdev/profiles/
echo local-crossdev /usr/local/portage-crossdev/profiles/repo_name
PORTDIR_OVERLAY="/usr/local/portage-crossdev" crossdev -S --target x86_64-elf

Unfortunately, I've never got this to work :(

Clone this wiki locally