Skip to content

Instantly share code, notes, and snippets.

@bashish2711
Forked from m-ou-se/instructions.txt
Created May 30, 2018 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bashish2711/8e510676a4c17767383a7976ad1cc474 to your computer and use it in GitHub Desktop.
Save bashish2711/8e510676a4c17767383a7976ad1cc474 to your computer and use it in GitHub Desktop.
Compiling a cross compiler for armv7l-unknown-linux-gnueabihf (RPi3)
wget http://ftp.snt.utwente.nl/pub/software/gnu/binutils/binutils-2.29.tar.xz
wget ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-7.2.0/gcc-7.2.0.tar.xz
wget http://ftp.gnu.org/gnu/glibc/glibc-2.26.tar.xz
tar xvf binutils-2.29.tar.xz
tar xvf gcc-7.2.0.tar.xz
cd binutils-2.29
./configure --target=armv7l-unknown-linux-gnueabihf --disable-multilib
make -j9
sudo make install
cd ..
scp drone:headers.tar.gz .
cd /usr/local/armv7l-unknown-linux-gnueabihf
sudo tar xzvf $OLDPWD/headers.tar.gz
cd -
cd gcc-7.2.0
./contrib/download_prerequisites
mkd ../gcc-build
../gcc-7.2.0/configure --enable-languages=c,c++,lto --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --target=armv7l-unknown-linux-gnueabihf --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16
make -j9 all-gcc
sudo make install-gcc
cd ..
tar xvf glibc-2.26.tar.xz
mkd glibc-build
../glibc-2.26/configure --prefix=/usr/local/armv7l-unknown-linux-gnueabihf --build=$MACHTYPE --host=armv7l-unknown-linux-gnueabihf --target=armv7l-unknown-linux-gnueabihf --with-headers=/usr/local/armv7l-unknown-linux-gnueabihf/include --disable-multilib libc_cv_forced_unwind=yes
make -j9 # This fails, but it does succeed buildling the parts we need now.
sudo make install-bootstrap-headers=yes install-headers
sudo install csu/crt1.o csu/crti.o csu/crtn.o /usr/local/armv7l-unknown-linux-gnueabihf/lib/
sudo touch /usr/local/armv7l-unknown-linux-gnueabihf/include/gnu/stubs.h
sudo /usr/local/bin/armv7l-unknown-linux-gnueabihf-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /usr/local/armv7l-unknown-linux-gnueabihf/lib/libc.so
cd ../gcc-build
make -j9 all-target-libgcc
sudo make install-target-libgcc
cd ../glibc-build
make -j9
sudo make install
cd ../gcc-build
make -j9
sudo make install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment