参考博客:
https://blog.csdn.net/u011622208/article/details/102542268
https://blog.csdn.net/aBlueMouse/article/details/78145802
大体流程跟着上面走其实并没有问题,但关键就在于最初的时候,会冒出些问题
比如:
问题零
不同路径下编译,出现的问题不同,甚至有的时候在相同路径下编译,都会出现不同的问题,所以,当make不成功的时候,多试几次或者换个路径多试几次,我装了四五遍才成功装好,一把心酸泪。
问题一
c compiler not found
解决办法:
通过命令行安装一个gcc
sudo apt install gcc-8 g++-8
说来也奇怪,明明gcc5.4也是gcc,安装5.4之前却还需要安装一个gcc,应该是gcc5.4的环境依赖未配置好,所以需要提前安装一个其他版本的gcc配置环境。
安装完后
gcc -v
用该代码检查下gcc的版本,如果有版本信息输出就代表gcc安装成功,再去configure,就可以顺利通过啦
我在安装完gcc后,用gcc -v查询版本时,查询出来的版本还是之前那个已经被我删除的版本,再找了一个程序,进行测试时,报错,在网上查询更换gcc版本的教程,更换到新安装的gcc版本,就可以顺利编译通过了。
编译通过。
编译通过后,按照上面两篇博客里的教程,一步步走即可。
make时间较长,耐心一步步等待,中间有可能会报错如下
问题二
./md-unwind-support.h:65:48: error: dereferencing pointer to incomplete type 'struct ucontext'
sc = (struct sigcontext *)(void *) &uc_->uc_mcontext);
解决方法为
大约65行左右的代码 struct ucontext * uc_ = context->cfa改成如下
struct ucontext_t * uc_ = context->cfa//多了一个——t
再重新make,报错如下
问题三
libtool: link: ar rc .libs/libcilkrts.a cilk-abi-vla.o os-unix-sysdep.o bug.o cilk-abi.o cilk-abi-cilk-for.o cilk-abi-vla-internal.o cilk_api.o cilk_fiber.o cilk_fiber-unix.o cilk_malloc.o c_reducers.o except-gcc.o frame_malloc.o full_frame.o global_state.o jmpbuf.o local_state.o metacall_impl.o os_mutex-unix.o os-unix.o pedigrees.o record-replay.o reducer_impl.o scheduler.o signal_node.o spin_mutex.o stats.o symbol_test.o sysdep-unix.o worker_mutex.o
libtool: link: ranlib .libs/libcilkrts.a
libtool: link: ( cd ".libs" && rm -f "libcilkrts.la" && ln -s "../libcilkrts.la" "libcilkrts.la" )
make[2]: Leaving directory '/home/ning/software/gcc-5.4.0/build/x86_64-unknown-linux-gnu/libcilkrts'
make[1]: Leaving directory '/home/ning/software/gcc-5.4.0/build'
Makefile:910: recipe for target 'all' failed
make: *** [all] Error 2
其实根本没有实际错误,但还是失败,所以,更换build路径试一试
更换路径后还是一样的问题
//所以在gcc5.4.0根目录下执行make,该问题解决
//将build和gcc放在同一级目录下,重新编译,问题解决
又重装了两次gcc发现,不需要更换目录,make编译停止后直接再次make就可以继续了,不需要更换build路径
问题四
../../.././libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc:237:22: error: aggregate 'sigaltstack handler_stack' has incomplete type and cannot be defined
struct sigaltstack handler_stack;
^
Makefile:449: recipe for target 'sanitizer_stoptheworld_linux_libcdep.lo' failed
make[4]: *** [sanitizer_stoptheworld_linux_libcdep.lo] Error 1
make[4]: Leaving directory '/home/ning/software/gcc-5.4.0/x86_64-unknown-linux-gnu/libsanitizer/sanitizer_common'
Makefile:437: recipe for target 'all-recursive' failed
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory '/home/ning/software/gcc-5.4.0/x86_64-unknown-linux-gnu/libsanitizer'
Makefile:307: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/ning/software/gcc-5.4.0/x86_64-unknown-linux-gnu/libsanitizer'
Makefile:16925: recipe for target 'all-target-libsanitizer' failed
make[1]: *** [all-target-libsanitizer] Error 2
make[1]: Leaving directory '/home/ning/software/gcc-5.4.0'
Makefile:910: recipe for target 'all' failed
make: *** [all] Error 2
参考网站https://reviews.llvm.org/D35246
将/sanitizer_stoptheworld_linux_libcdep.cc中第237行
struct sigaltstack handler_stack;
修改为
stack_t handler_stack;
重新编译,发现还是有几处问题,按照上面网址中的内容,全部修改即可。
问题五
../../.././libsanitizer/asan/asan_linux.cc: In function 'bool __asan::AsanInterceptsSignal(int)':
../../.././libsanitizer/asan/asan_linux.cc:222:20: error: 'SIGSEGV' was not declared in this scope
return signum == SIGSEGV && common_flags()->handle_segv;
^
Makefile:461: recipe for target 'asan_linux.lo' failed
make[4]: *** [asan_linux.lo] Error 1
参考网站https://bugs.busybox.net/show_bug.cgi?id=10061
在asan_linux.cc中添加头文件#include <signal.h>即可
问题六
…/…/…/…/libsanitizer/tsan/tsan_platform_linux.cc: In function ‘int __tsan::ExtractResolvFDs(void*, int*, int)’:
…/…/…/…/libsanitizer/tsan/tsan_platform_linux.cc:290:16: error: ‘statp’ was not declared in this scope
__res_state statp = (__res_state)state;
^~~~~
…/…/…/…/libsanitizer/tsan/tsan_platform_linux.cc:290:16: note: suggested alternative: ‘state’
__res_state statp = (__res_state)state;
将第一行代码修改为第二行即可
__res_state *statp = (__res_state*)state;
struct __res_state *statp = (struct __res_state*)state;
重新编译
就可以成功了