Skip to content

Instantly share code, notes, and snippets.

@lirenlin
Last active October 1, 2023 16:57
Show Gist options
  • Save lirenlin/a40d4b510799fa31acba to your computer and use it in GitHub Desktop.
Save lirenlin/a40d4b510799fa31acba to your computer and use it in GitHub Desktop.
build cross arm-gcc with newlib

##Set environment variables

export TARGET=aarch64-none-elf
export PREFIX=/work/public/$TARGET
export PATH=$PATH:$PREFIX/bin

##Build binutils

mkdir build-binutils
cd build-binutils
../binutils-source/configure --target=$TARGET --prefix=$PREFIX
make all
make install

##Prerequisite libs

cd gcc-source
bash ./contrib/download_prerequisites
cd ..

prerequisite libs (GMP/MPFR/MPC), put them into gcc director, and link statically.

If not, the system gmp/mpft/mpc libraries will be used, and linked dynamically.

http://advogato.org/person/redi/diary/253.html

##Build gcc

mkdir build-gcc
cd build-gcc
../gcc-source/configure --target=$TARGET --prefix=$PREFIX --without-header --with-newlib --with-gnu-as --with-gnu-ld --enable-lto --enable-linker-build-id --disable-libmudflap --disable-libgomp --disable-libssp --disable-libstdcxx-pch --enable-multiarch --disable-multilib --enable-languages=c,c++ --with-headers=../newlib-source/newlib/libc/include --disable-shared
make
make install

##Build newlib

mkdir build-newlib
cd build-newlib
../newlib-source/configure --target=$TARGET --prefix=$PREFIX
make -j8
make install

##Build GCC again with newlib

cd build-gcc
make -j8
make install

##Build GDB

mkdir build-gdb
cd build-gdb
../gdb-source/configure --target=$TARGET --prefix=$PREFIX --enable-interwork

##Errors ###checking for the value of EOF... configure: error: computing EOF failed --with-headers=../newlib-source/newlib/libc/include ###error while loading shared libraries: libmpc.so.2 Please refer [step 3](#Prerequisite libs)

@4ntoine
Copy link

4ntoine commented Jun 15, 2020

is it the same issue? jcmvbkbc/crosstool-NG#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment