ubuntu 20.04LST跌跌撞撞安装编译gcc6.3.0

ubuntu 20.04LST跌跌撞撞安装gcc6.3.0

  • 下载
    • 安装依赖包
    • 安装
    • 编译过程中出现的问题
      • 问题1:error: dereferencing pointer to incomplete type 'struct ucontext'
      • 解决方案:
      • 问题2:sanitizer_platform_limits_posix.cc:158:23: 致命错误:sys/ustat.h:没有那个文件或目录
      • 解决方案:
      • 问题3:
      • 解决方案:
      • 问题4:sanitizer_common/sanitizer_internal_defs.h:254:72: error: size of array ‘assertion_failed__1142’ is negative
      • 解决方案:

下载

首先在官网上下载gcc6.3.0,链接如下:
https://ftp.gnu.org/gnu/gcc/gcc-6.3.0/

安装依赖包

按顺序安装gcc必备的几个包:m4、gmp、mpfr、mpc

m4:

./contrib/download_prerequisites

gmp(http://www.gnu.org/software/m4/):

文件夹打开终端
./configure
make -j12
sudo make install

mpfr(https://mpfr.loria.fr/):

文件夹打开终端
./configure
make -j12
sudo make install

mpc(https://www.multiprecision.org/mpc/ ):

文件夹打开终端
./configure
make -j12
sudo make install

安装

找到下载的文件,提取,文件夹内打开终端

sudo ./configure --prefix=/usr/local/gcc-6.3 --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=$HOME/local/ --with-mpfr=$HOME/local/ --with-cgal=$HOME/local/
make -j12 # j 后面的数字越大编译速度越快
sudo make install

编译过程中出现的问题

问题1:error: dereferencing pointer to incomplete type ‘struct ucontext’

在函数‘x86_64_fallback_frame_state’中: ./md-unwind-support.h:65:47: 错误: dereferencing pointer to incomplete type ‘struct ucontext’       
 sc = (struct sigcontext *) (void *) &uc_->uc_mcontext;    

解决方案:

 struct ucontext * uc_ = context->cfa; 

修改为

struct ucontext_t * uc_ = context->cfa; 

重新make

问题2:sanitizer_platform_limits_posix.cc:158:23: 致命错误:sys/ustat.h:没有那个文件或目录

../../.././libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:159:
28: fatal error: sys/ustat.h: No such file or directory
 #include 
                       ^
compilation terminated.

解决方案:

修改libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc文件:

vim libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc

首先注释掉 #include
接着在 251 行修改 unsigned struct_ustat_sz = sizeof(struct ustat); 语句
注释掉251行,换行后粘贴以下内容:

  // Use pre-computed size of struct ustat to avoid  which
  // has been removed from glibc 2.28.
#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
  || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
  || defined(__x86_64__)
#define SIZEOF_STRUCT_USTAT 32
#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
  || defined(__powerpc__) || defined(__s390__)
#define SIZEOF_STRUCT_USTAT 20
#else
#error Unknown size of struct ustat
#endif
  unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;

重新make

问题3:

../../.././libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:270:22: 错误: 聚
合‘sigaltstack handler_stack’类型不完全,无法被定义
   struct sigaltstack handler_stack;
                      ^~~~~~~~~~~~~

解决方案:

1.打开libsanitizer/sanitizer_common/sanitizer_linux.h文件,注释第22行的struct sigaltstack;
2.修改31.32行:

uptr internal_sigaltstack(const struct sigaltstack* ss,
                          struct sigaltstack* oss);

修改为

uptr internal_sigaltstack(const void* ss, void* oss);

3.修改libsanitizer/sanitizer_common/sanitizer_linux.cc文件549、550行

uptr internal_sigaltstack(const struct sigaltstack *ss,                                      
                                struct sigaltstack *oss) {

修改为

uptr internal_sigaltstack(const void *ss, void *oss) {

4.修改libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc270行

struct sigaltstack handler_stack;

修改为

stack_t handler_stack;

5.修改libsanitizer/tsan/tsan_platform_linux.cc294行

__res_state *statp = (__res_state*)state;

修改为

struct __res_state *statp = (struct __res_state*)state;

重新make

问题4:sanitizer_common/sanitizer_internal_defs.h:254:72: error: size of array ‘assertion_failed__1142’ is negative

解决方案:

修改 /gcc-6.3.0/configure文件

删除文件中 target-libsanitizer \,大概在两千多行
重新make

ubuntu 20.04LST跌跌撞撞安装编译gcc6.3.0_第1张图片

你可能感兴趣的:(BUG,ubuntu,linux,运维)