一、准备
环境:ubuntu22.04为刚刚安装,未安装gcc等包
vi ~/.bashrc输入
export PATH=$PATH:/opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin
保存,reboot
安装:
sudo apt install cmake
sudo apt install gawk
sudo apt install bison
第一步:安装glibc-2.34
mkdir build
cd build../configure --prefix=${PWD}/install \
--build=arm-linux-gnu \
--host=arm-linux-gnu \
--target=arm-linux-gnu \
CC=arm-linux-gnueabihf-gcc \
CXX=arm-linux-gnueabihf-g++ \
CPP=arm-linux-gnueabihf-cpp \
--disable-multilib libc_cv_forced_unwind=yesmake
make install
第二步:编译gmp-6.1.0
./configure --prefix=${PWD}/install/ --host=arm-linux --disable-assembly CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++make
make install
第三步:编译mpfr-3.1.4
./configure --prefix=${PWD}/install --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-gmp=/opt/gmp-6.1.0/installmake
make install
第四步:编译mpc-1.03
./configure --prefix=${PWD}/install --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-gmp=/opt/gmp-6.1.0/install --with-mpfr=/opt/mpfr-3.1.4/installmake
make install
第五步:编译isl-0.18
将/opt/gmp-6.1.0/install/lib目录下所有库文件拷贝到gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib/,
然后执行
./configure --prefix=${PWD}/install --host=arm-linux CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ --with-gmp-prefix=/opt/gmp-6.1.0/installmake
make install
第六步:编译gcc-9.5
删除cc
cd /usr/bin
sudo rm cc
sudo ln -s /opt/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc cc
reboot
然后安装一些库,要不然编译不过
sudo apt-get install lsb-core lib32stdc++6
然后执行
./configure --prefix=${PWD}/build \
--with-gmp=/opt/gmp-6.1.0/install \
--with-mpfr=/opt/mpfr-3.1.4/install \
--with-mpc=/opt/mpc-1.0.3/install \
--with-isl=/opt/isl-0.18/install \
CC=arm-linux-gnueabihf-gcc \
CXX=arm-linux-gnueabihf-g++ \
CPP=arm-linux-gnueabihf-cpp \
--host=arm-linux-gnueabihf \
--target=arm-linux-gnueabihf \
--with-newlib \
--without-headers \
--enable-initfini-array \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-checking=release \
--enable-languages=c,c++make -j8 all-gcc
make install-gcc
编译结果
编译gmp遇到问题:
问题:Oops, mp_limb_t is 64 bits, but the assembler code
解决:https://gist.github.com/cwoac/5844398
I realised the first failure was because it tried to build the 64 bit code on a 32 bit platform.
The attached gist is the failure when running with --32-bit.
This can be worked around by adding --disable-assembly to the configure call
同时:
sudo apt-get install m4
备注:
gcc-9.5源码根目录/contrib/download_prerequisites 里面地有需要依赖的库源码版本,可以直接执行./contrib/download_prerequisites下载