Today, let's try to build the MOST RECENTGCC 9.1. We strictly follow the
TERRIFIC blog How
to Build a GCC Cross-Compiler with trivial modifications for my
x86_64 desktop instead of aarch64
cross compile.
Preparations
Packages Required on HOST
Some packages are required to install on the host computer,
including: * g++ * make * gawk * bison * flex * expect * gnat etc.
Get ALL Packages for Building
GCC
A wget-list.txt
file is provided to download ALL required packages
up-to-date. After having downloaded this single text file, the
UNIQUE command to download all files is as follows:
1
➜ gcc ✗ wget -i wget-list.txt
You can of course download the files one by one. All concerned files
are listed below: *
https://gnu.freemirror.org/gnu/binutils/binutils-2.32.tar.gz *
https://gnu.freemirror.org/gnu//gcc/gcc-9.1.0/gcc-9.1.0.tar.gz *
https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.1.12.tar.gz
* https://ftp.gnu.org/glibc/glibc-2.29.tar.xz *
https://ftp.gnu.org/mpfr/mpfr-4.0.2.tar.xz *
https://ftp.gnu.org/gmp/gmp-6.1.2.tar.xz *
https://ftp.gnu.org/mpc/mpc-1.1.0.tar.gz *
ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.18.tar.bz2 *
ftp://gcc.gnu.org/pub/gcc/infrastructure/cloog-0.18.1.tar.gz
Then, we extract all .tar files in whatever way you
prefer.
➜ gcc mkdir build-binutils ➜ gcc cd build-binutils ➜ build-binutils ../binutils-2.32/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-vtable-verify checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for a sed that does not truncate output... /usr/bin/sed checking for gawk... gawk checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking for g++... g++ checking whether we are using the GNU C++ compiler... yes checking whether g++ accepts -g... yes checking whether g++ accepts -static-libstdc++ -static-libgcc... yes checking for gnatbind... gnatbind checking for gnatmake... gnatmake checking whether compiler driver understands Ada... yes checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2 checking for objdir... .libs checking for isl 0.15 or later... no required isl version is 0.15 or later checking for default BUILD_CONFIG... checking for --enable-vtable-verify... yes checking for bison... bison -y checking for bison... bison checking for gm4... no checking for gnum4... no checking for m4... m4 checking for flex... flex checking for flex... flex checking for makeinfo... makeinfo checking for expect... expect checking for runtest... no checking for ar... ar checking for as... as checking for dlltool... no checking for ld... ld checking for lipo... no checking for nm... nm checking for ranlib... ranlib checking for strip... strip checking for windres... no checking for windmc... no checking for objcopy... objcopy checking for objdump... objdump checking for readelf... readelf checking for x86_64-linux-gnu-cc... no checking for cc... cc checking for x86_64-linux-gnu-c++... no checking for c++... c++ checking for x86_64-linux-gnu-gcc... x86_64-linux-gnu-gcc checking for x86_64-linux-gnu-gfortran... x86_64-linux-gnu-gfortran checking for x86_64-linux-gnu-gccgo... no checking for gccgo... no checking for x86_64-linux-gnu-ar... x86_64-linux-gnu-ar checking for x86_64-linux-gnu-as... x86_64-linux-gnu-as checking for x86_64-linux-gnu-dlltool... no checking for dlltool... no checking for x86_64-linux-gnu-ld... x86_64-linux-gnu-ld checking for x86_64-linux-gnu-lipo... no checking for lipo... no checking for x86_64-linux-gnu-nm... x86_64-linux-gnu-nm checking for x86_64-linux-gnu-objcopy... x86_64-linux-gnu-objcopy checking for x86_64-linux-gnu-objdump... x86_64-linux-gnu-objdump checking for x86_64-linux-gnu-ranlib... x86_64-linux-gnu-ranlib checking for x86_64-linux-gnu-readelf... x86_64-linux-gnu-readelf checking for x86_64-linux-gnu-strip... x86_64-linux-gnu-strip checking for x86_64-linux-gnu-windres... no checking for windres... no checking for x86_64-linux-gnu-windmc... no checking for windmc... no checking where to find the target ar... just compiled checking where to find the target as... just compiled checking where to find the target cc... host tool checking where to find the target c++... host tool checking where to find the target c++ for libstdc++... host tool checking where to find the target dlltool... just compiled checking where to find the target gcc... host tool checking where to find the target gfortran... host tool checking where to find the target gccgo... host tool checking where to find the target ld... just compiled checking where to find the target lipo... host tool checking where to find the target nm... just compiled checking where to find the target objcopy... just compiled checking where to find the target objdump... just compiled checking where to find the target ranlib... just compiled checking where to find the target readelf... just compiled checking where to find the target strip... just compiled checking where to find the target windres... just compiled checking where to find the target windmc... just compiled checking whether to enable maintainer-specific portions of Makefiles... no configure: creating ./config.status config.status: creating Makefile ➜ build-binutils make -j4 ...... ➜ build-binutils make install ➜ build-binutils cd ..
Linux Kernel Headers
1 2 3
➜ gcc cd linux-5.1.12 ➜ linux-5.1.12 make ARCH=x86 INSTALL_HDR_PATH=/opt/native/linux headers_install ➜ linux-5.1.12 cd ..
C/C++ Compilers
1 2 3 4 5 6
➜ gcc mkdir -p build-gcc ➜ gcc cd build-gcc ➜ build-gcc ../gcc-9.1.0/configure --prefix=/opt/native --target=x86_64-linux-gnu --enable-languages=c,c++,fortran,go --disable-multilib --enable-vtable-verify ➜ build-gcc make -j4 all-gcc ➜ build-gcc make install-gcc ➜ build-gcc cd ..