searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

信创环境编译gcc5.4

2024-07-26 09:57:21
25
0

1.先下载 gcc5.4 的依赖包 gmp mpfr 和 mpc

gmp: https://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.gz

mpfr: https://ftp.gnu.org/gnu/mpfr/mpfr-2.4.2.tar.gz

mpc: https://ftp.gnu.org/gnu/mpc/mpc-1.0.1.tar.gz

gcc: http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-5.4.0/gcc-5.4.0.tar.gz

2.gmp编译安装

1.下载gmp,并解压,去到解压后的文件夹

2.去到以下地址

http://git.savannah.gnu.org/gitweb/?p=config.git**;a=blob_plain;f=config.guess;hb=HEAD**

http://git.savannah.gnu.org/gitweb/?p=config.git**;a=blob_plain;f=config.sub;hb=HEAD**

将新的脚本下载下来,替换解压后文件夹里的 config.guess 和 config.sub的文件内容

3.编译。执行如下命令(后面地址为解压文件后的地址)

./configure --prefix=/home/integraTors/opt/gmp4.3.2
make
make install prefix=/home/integraTors/opt/gmp4.3.2
#检查是否安装成功
ldconfig -p | grep libgmp

 

3.mpfr编译安装

1.下载mpfr,并解压。去到解压后的文件夹

2.编译。执行如下命令(后面地址为解压文件后的地址)

#编译mpfr依赖gmp库 所以需要如下写命令
./configure --prefix=/home/integraTors/opt/mpfr2.4.2 CFLAGS="-I/home/integraTors/opt/gmp4.3.2/include" LDFLAGS="-L/home/integraTors/opt/gmp4.3.2/lib"
#编译
make
#安装
make install prefix=/home/integraTors/opt/mpfr2.4.2
#检查
ldconfig -p | grep libmpfr

 

4.mpc编译安装

1.下载mpc,并解压。去到解压后的文件夹

2.编译。执行如下命令(后面地址为解压文件后的地址)

#配置 需要依赖mpfr和gmp
./configure --prefix=/home/integraTors/opt/mpc1.0.1 CFLAGS="-I/home/integraTors/opt/gmp4.3.2/include -I/home/integraTors/opt/mpfr2.4.2/include" LDFLAGS="-L/home/integraTors/opt/gmp4.3.2/lib -L/home/integraTors/opt/mpfr2.4.2/lib"
#编译
make
#安装
make install prefix=/home/integraTors/opt/mpc1.0.1
#检查
ldconfig -p | grep libmpc

 

5.编译GCC5.4

1.设置环境变量

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/integraTors/opt/gmp4.3.2/lib:/home/integraTors/opt/mpfr2.4.2/lib:/home/integraTors/opt/mpc1.0.1/lib

2.下载gcc5.4,并解压。去到解压后的文件夹

3.编译。执行如下命令(后面地址为解压文件后的地址)

#配置
./configure --prefix=/home/integraTors/opt/gcc5.4.0 --enable-bootstrap --enable-languages=c,c++,fortran,lto --enable-shared --enable-threads=posix --disable-multilib --disable-libsanitizer  --with-gmp=/home/integraTors/opt/gmp4.3.2 --with-mpfr=/home/integraTors/opt/mpfr2.4.2 --with-mpc=/home/integraTors/opt/mpc1.0.1

#编译 make -j48

#编译发现问题 日志:/home/integraTors/gcc-5.4.0/aarch64-unknown-linux-gnu/libgcc/config.log 
configure:3460: /home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/xgcc -B/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/bin/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/lib/ -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/include -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/sys-include    -o conftest -g -O2   conftest.c  >&5
/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory
configure:3463: $? = 1
configure:3651: checking for suffix of object files
configure:3673: /home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/xgcc -B/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/bin/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/lib/ -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/include -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/sys-include    -c -g -O2  conftest.c >&5
/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory

#做软链接
ln -s /home/integraTors/opt/mpfr2.4.2/lib/libmpfr.so.1.2.2  /usr/lib/libmpfr.so
ln -s /home/integraTors/opt/mpfr2.4.2/lib/libmpfr.so.1.2.2  /usr/lib/libmpfr.so.1
ln -s /home/integraTors/opt/gmp-4.3.2/lib/libgmp.so.3.5.2 /usr/lib/libgmp.so
ln -s /home/integraTors/opt/gmp-4.3.2/lib/libgmp.so.3.5.2 /usr/lib/libgmp.so.3

ln -s /home/integraTors/opt/gmp4.3.2/lib/libgmp.so.3.5.2 /usr/lib64/libgmp.so.3
ln -s /home/integraTors/opt/mpfr2.4.2/lib/libmpfr.so.1.2.2 /usr/lib64/libmpfr.so.1

#编译 make -j48 报错
In file included from ../.././libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘aarch64_fallback_frame_state’:
./md-unwind-support.h:55:21: error: field ‘uc’ has incomplete type
     struct ucontext uc;
这里是因为定义问题导致出错了
找到md-unwind-support.h文件:/home/integraTors/gcc-5.4.0/aarch64-unknown-linux-gnu/libgcc/md-unwind-support.h  修改代码片段
  struct rt_sigframe
  {
    siginfo_t info;
    struct ucontext uc;
  };
  为
  struct rt_sigframe
  {
    siginfo_t info;
    struct ucontext_t uc;
  };
  
 #继续编译 make -j48 成功
 
 #安装
 make install prefix=/home/integraTors/opt/gcc5.4.0
0条评论
0 / 1000
汤****澈
8文章数
0粉丝数
汤****澈
8 文章 | 0 粉丝
原创

信创环境编译gcc5.4

2024-07-26 09:57:21
25
0

1.先下载 gcc5.4 的依赖包 gmp mpfr 和 mpc

gmp: https://ftp.gnu.org/gnu/gmp/gmp-4.3.2.tar.gz

mpfr: https://ftp.gnu.org/gnu/mpfr/mpfr-2.4.2.tar.gz

mpc: https://ftp.gnu.org/gnu/mpc/mpc-1.0.1.tar.gz

gcc: http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-5.4.0/gcc-5.4.0.tar.gz

2.gmp编译安装

1.下载gmp,并解压,去到解压后的文件夹

2.去到以下地址

http://git.savannah.gnu.org/gitweb/?p=config.git**;a=blob_plain;f=config.guess;hb=HEAD**

http://git.savannah.gnu.org/gitweb/?p=config.git**;a=blob_plain;f=config.sub;hb=HEAD**

将新的脚本下载下来,替换解压后文件夹里的 config.guess 和 config.sub的文件内容

3.编译。执行如下命令(后面地址为解压文件后的地址)

./configure --prefix=/home/integraTors/opt/gmp4.3.2
make
make install prefix=/home/integraTors/opt/gmp4.3.2
#检查是否安装成功
ldconfig -p | grep libgmp

 

3.mpfr编译安装

1.下载mpfr,并解压。去到解压后的文件夹

2.编译。执行如下命令(后面地址为解压文件后的地址)

#编译mpfr依赖gmp库 所以需要如下写命令
./configure --prefix=/home/integraTors/opt/mpfr2.4.2 CFLAGS="-I/home/integraTors/opt/gmp4.3.2/include" LDFLAGS="-L/home/integraTors/opt/gmp4.3.2/lib"
#编译
make
#安装
make install prefix=/home/integraTors/opt/mpfr2.4.2
#检查
ldconfig -p | grep libmpfr

 

4.mpc编译安装

1.下载mpc,并解压。去到解压后的文件夹

2.编译。执行如下命令(后面地址为解压文件后的地址)

#配置 需要依赖mpfr和gmp
./configure --prefix=/home/integraTors/opt/mpc1.0.1 CFLAGS="-I/home/integraTors/opt/gmp4.3.2/include -I/home/integraTors/opt/mpfr2.4.2/include" LDFLAGS="-L/home/integraTors/opt/gmp4.3.2/lib -L/home/integraTors/opt/mpfr2.4.2/lib"
#编译
make
#安装
make install prefix=/home/integraTors/opt/mpc1.0.1
#检查
ldconfig -p | grep libmpc

 

5.编译GCC5.4

1.设置环境变量

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/integraTors/opt/gmp4.3.2/lib:/home/integraTors/opt/mpfr2.4.2/lib:/home/integraTors/opt/mpc1.0.1/lib

2.下载gcc5.4,并解压。去到解压后的文件夹

3.编译。执行如下命令(后面地址为解压文件后的地址)

#配置
./configure --prefix=/home/integraTors/opt/gcc5.4.0 --enable-bootstrap --enable-languages=c,c++,fortran,lto --enable-shared --enable-threads=posix --disable-multilib --disable-libsanitizer  --with-gmp=/home/integraTors/opt/gmp4.3.2 --with-mpfr=/home/integraTors/opt/mpfr2.4.2 --with-mpc=/home/integraTors/opt/mpc1.0.1

#编译 make -j48

#编译发现问题 日志:/home/integraTors/gcc-5.4.0/aarch64-unknown-linux-gnu/libgcc/config.log 
configure:3460: /home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/xgcc -B/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/bin/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/lib/ -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/include -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/sys-include    -o conftest -g -O2   conftest.c  >&5
/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory
configure:3463: $? = 1
configure:3651: checking for suffix of object files
configure:3673: /home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/xgcc -B/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/bin/ -B/home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/lib/ -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/include -isystem /home/integraTors/opt/gcc5.4.0/aarch64-unknown-linux-gnu/sys-include    -c -g -O2  conftest.c >&5
/home/integraTors/gcc-5.4.0/host-aarch64-unknown-linux-gnu/gcc/cc1: error while loading shared libraries: libmpfr.so.1: cannot open shared object file: No such file or directory

#做软链接
ln -s /home/integraTors/opt/mpfr2.4.2/lib/libmpfr.so.1.2.2  /usr/lib/libmpfr.so
ln -s /home/integraTors/opt/mpfr2.4.2/lib/libmpfr.so.1.2.2  /usr/lib/libmpfr.so.1
ln -s /home/integraTors/opt/gmp-4.3.2/lib/libgmp.so.3.5.2 /usr/lib/libgmp.so
ln -s /home/integraTors/opt/gmp-4.3.2/lib/libgmp.so.3.5.2 /usr/lib/libgmp.so.3

ln -s /home/integraTors/opt/gmp4.3.2/lib/libgmp.so.3.5.2 /usr/lib64/libgmp.so.3
ln -s /home/integraTors/opt/mpfr2.4.2/lib/libmpfr.so.1.2.2 /usr/lib64/libmpfr.so.1

#编译 make -j48 报错
In file included from ../.././libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function ‘aarch64_fallback_frame_state’:
./md-unwind-support.h:55:21: error: field ‘uc’ has incomplete type
     struct ucontext uc;
这里是因为定义问题导致出错了
找到md-unwind-support.h文件:/home/integraTors/gcc-5.4.0/aarch64-unknown-linux-gnu/libgcc/md-unwind-support.h  修改代码片段
  struct rt_sigframe
  {
    siginfo_t info;
    struct ucontext uc;
  };
  为
  struct rt_sigframe
  {
    siginfo_t info;
    struct ucontext_t uc;
  };
  
 #继续编译 make -j48 成功
 
 #安装
 make install prefix=/home/integraTors/opt/gcc5.4.0
文章来自个人专栏
文档数据库服务
7 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0