This is a record of how I compile GCC 9.1 for ARM64 on Ubuntu 18.04.
Environment
1. Host Environment
host : Ubuntu 18.04
GCC version : 9.1.0(you may use defalut compiler of your Ubuntu)
Binutils version : 2.3
Glibc version : 2.27
Bison version : 3.0.4
Flex version : 2.6.4
GMP version : 6.1.2
MPC version : 1.1.0
MPFR version : 4.0.1
Texinfo version : 6.5.0
CLooG version : 0.18.4
ISL version : 0.19
2. Target
Source dir : /media/cliff/Work2/testKernel/src/
Target dir : $HOME/opt/cross
Gcc version : 9.1
Binutils version : 2.32
Linux kernel version : 5.0.1
Glibc version : 2.30
Step
1. Download Source
You can download source files from following sites.
cd /media/cliff/Work2/testKernel/src/ mkdir build-binutils cd build-binutils ../binutils-2.32/configure --target=$TARGET --prefix=$PREFIX --with-sysroot --disable-multilib make -j12 make install cd ..
4. Linux Kernel Headers
1 2 3
cd linux-5.0.1 make ARCH=arm64 INSTALL_HDR_PATH=$PREFIX/$TARGET headers_install cd ..
5. Build Gcc
1 2 3 4 5 6
mkdir -p build-gcc cd build-gcc ../gcc-9.1/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ --disable-multilib make -j12 all-gcc make install-gcc cd ..
6. Build Glibc
1 2 3 4 5 6 7 8 9
mkdir -p build-glibc cd build-glibc ../glibc-2.30/configure --prefix=$PREFIX/$TARGET --build=$MACHTYPE --host=aarch64-linux --target=aarch64-linux --with-headers=$PREFIX/$TARGET/include --disable-multilib libc_cv_forced_unwind=yes make install-bootstrap-headers=yes install-headers make -j12 csu/subdir_lib install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/$TARGET/lib aarch64-linux-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PREFIX/$TARGET/lib/libc.so touch $PREFIX/$TARGET/include/gnu/stubs.h cd ..
7. Compiler Support Library
1 2 3 4
cd build-gcc make -j12 all-target-libgcc make install-target-libgcc cd ..