Skip to content

Instantly share code, notes, and snippets.

@vlad-ivanov-name
Forked from lirenlin/build-gcc.md
Last active April 18, 2021 11:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vlad-ivanov-name/1b55beed32f3eb3f90513896565ef5c0 to your computer and use it in GitHub Desktop.
Save vlad-ivanov-name/1b55beed32f3eb3f90513896565ef5c0 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 to step 3

@darklukee
Copy link

Don't use --with-headers=../newlib-source/newlib/libc/include
Use --without-headers, and then on second gcc build configure it again, this time without --without-headers
See this for explanation.

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