在X86上,我需要为arm64构建一个gcc交叉编译器,其内容如下:
binutils-2.26.1.tar.gz gcc-5.4.0.tar.gz glibc-2.23.tar.gz gmp-6.1.2.tar.bz2 mpc-1.1.0.tar.gz mpfr-4.0.1.tar.gz
我已将它们全部放入名为download
的目录中。
在阅读以下链接:http://preshing.com/20141119/how-to-build-a-gcc-cross-compiler/之后,我编写了如下的bash脚本来构建gcc交叉编译器:
#!/bin/bash
sudo rm -rf build sources /opt/aarch64-linux-gnu-5.4.0
mkdir build
cp -r download sources
cd sources
for f in *.tar*; do tar xf $f; done
cd gcc-5.4.0/
ln -s ../mpfr-4.0.1 mpfr
ln -s ../mpc-1.1.0 mpc
ln -s ../gmp-6.1.2 gmp
cd ../..
export PREFIX=/opt/aarch64-linux-gnu-5.4.0
#export PATH=$PREFIX/bin:$PATH
export SYSROOT=$PREFIX/sysroot
export TARGET=aarch64-linux-gnu
cd build
mkdir binutils && cd binutils
../../sources/binutils-2.26.1/configure --prefix=/$PREFIX --target=$TARGET
make -j32
make install
cd ..
cd /home/me/projet/kernel/linux-4.1
make ARCH=arm64 INSTALL_HDR_PATH=$PREFIX/aarch64-linux-gnu/include headers_install
cd -
mkdir gcc && cd gcc
../../sources/gcc-5.4.0/configure --prefix=$PREFIX --target=$TARGET --enable-languages=c,c++ --without-headers
make -j32 all-gcc
make install-gcc
cd ..
mkdir -p glibc && cd glibc
../../sources/glibc-2.23/configure --prefix= --build=$MACHTYPE --host=$TARGET --target=$TARGET --with-headers=$PREFIX/aarch64-linux-gnu/include libc_cv_forced_unwind=yes
make prefix=$PREFIX/aarch64-linux-gnu install-bootstrap-headers=yes install-headers
make -j32 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/aarch64-linux-gnu/lib
/opt/aarch64-linux-gnu-5.4.0/bin/aarch64-linux-gnu-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $PREFIX/aarch64-linux-gnu/lib/libc.so
touch $PREFIX/aarch64-linux-gnu/include/gnu/stubs.h
cd ..
cd gcc
make -j32 all-target-libgcc
make install-target-libgcc
cd ..
cd glibc
make -j32
make prefix=$PREFIX/aarch64-linux-gnu install
cd ..
cd gcc
make -j32
make install
cd ..
但是,当我执行此bash脚本时,出现两个错误:
cc1: error: no include path in which to search for stdc-predef.h
In file included from ../../../../sources/gcc-5.4.0/libgcc/gthr.h:148:0,
from ../../../../sources/gcc-5.4.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory