Skip to content

Instantly share code, notes, and snippets.

@iori-yja
Created February 28, 2014 14:19
Show Gist options
  • Save iori-yja/9271860 to your computer and use it in GitHub Desktop.
Save iori-yja/9271860 to your computer and use it in GitHub Desktop.
Build cross compiler with newlib.
export PREFIX=/usr/local/$TARGET
export TARGET=arm-none-eabi-newlib
# build binutils
wget http://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2
tar xf binutils-2.24.tar.bz2
mkdir b-binutils
cd b-binutils
../binutils-2.24/configure --prefix=$PREFIX --program-prefix=arm-none-eabi- --target=arm-eabi --enable-lto --enable-interwork --enable-multilib
make -j5
sudo make install
export PATH=$PATH:$PREFIX/bin
# build gcc (stage 1)
cd ../
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-4.8.2/gcc-4.8.2.tar.bz2
mkdir b-gcc
cd b-gcc
../gcc-4.8.2/configure --prefix=$PREFIX --program-prefix=arm-none-eabi- --target=arm-eabi --enable-lto --enable-languages=c --without-headers --with-newlib --enable-interwork --enable-multilib --disable-shared --disable-thread
make -j5 all-gcc
sudo make install-gcc
# build newlib
cd ../
wget ftp://sources.redhat.com/pub/newlib/newlib-2.1.0.tar.gz
tar xf newlib-2.1.0.tar.gz
mkdir b-newlib
cd b-newlib
../newlib-2.1.0/configure --prefix=$PREFIX --target=arm-eabi --disable-newlib-supplied-syscalls
make -j5
sudo make install
# build gcc (stage 2)
cd ../
mkdir b-gcc2
cd b-gcc2
../gcc-4.8.2/configure --prefix=$PREFIX --program-prefix=arm-none-eabi- --target=arm-eabi
--enable-lto --enable-languages=c,c++ --with-newlib --enable-interwork --enable-multilib --disable-shared --disable-thread
make -j5
make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment