llvm 3.42 build from source fails on ubuntu 17.04

瘦欲@ 提交于 2019-11-29 17:41:36

That seems to be an issue with LLVM 3.4.2tsan (Thread Sanitizer) failing to build with GCC 6.x, as previously reported here:

https://aur.archlinux.org/packages/clang34-analyzer-split

It seems the inclusion of stdlib.h and malloc.h is conflicting, since both define malloc and friends.

It's possible that this issue only manifets in tsan, so if tsan is not instrumental to your LLVM build (which is very likely), and you wish to stick with the system gcc for building LLVM, you may consider disabling tsan completely.

If you're running a CMake build (as in here), you can do so by commenting line 29 of llvm/projects/compiler-rt/lib/CMakeLists.txt:

if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID)  
  add_subdirectory(tsan) # comment out this line

If you're forced to stick to the configure build, my best guess would be removing the tsan-x86_64 target in llvm/projects/compiler-rt/make/clang_linux.mk, line 63:

Configs += full-x86_64 profile-x86_64 san-x86_64 asan-x86_64 --> tsan-x86_64 <-- 

I faced the same problem on my Ubuntu 16.10. It has default gcc 6.2. You need to instruct LLVM build system to use gcc 4.9. Also, I suggest you remove GCC6 completely.

$ sudo apt-get remove g++-6 gcc-6 cpp
$ sudo apt-get install gcc-4.9 g++4.9
$ export CC=/usr/bin/gcc-4.9
$ export CXX=/usr/bin/g++-4.9
$ export CPP=/usr/bin/cpp-4.9
$ ./configure
$ make

And maybe you will need:

$ sudo ln -s /usr/bin/cpp-4.9 /usr/bin/cpp
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!