cmake不调用新版本gcc及third-party/benchmark不存在
在centos7上安装了8+版本的gcc,环境变量配了,- v查看没问题,cmake安装llvm,报错,一看还是调用了旧版本的gcc
cmake -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX=INSTALL_DIR -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_ASSERTIONS=On ../llvm-14.0.3.src
CMake Error at cmake/modules/CheckCompilerVersion.cmake:39 (message):
Host GCC version must be at least 5.1, your version is 4.8.5.
Call Stack (most recent call first):
cmake/modules/CheckCompilerVersion.cmake:49 (check_compiler_version)
cmake/config-ix.cmake:14 (include)
CMakeLists.txt:732 (include)
-- Configuring incomplete, errors occurred!
See also "/opt/llvmbuild/CMakeFiles/CMakeOutput.log".
查了下,貌似cmake默认会去调用/usr/bin和/usr/local/bin,因为我是手动编译安装所以残留有原来的旧版本的gcc,但是我修改了这两个目录下gcc的ln指向,依旧还是报同样的错误,去修改了ld.so.conf手动添加了新版本gcc的链接库,ldconfig了,ldconig -v / -p都能查到,但是运行后依旧报同样错误
解决方法:
cmake的时候手动指定编译要用的gcc和g++的路径
cmake -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX=/usr/local -DLLVM_INCLUDE_DIRS=/usr/local/gcc-9.4/lib64 -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_ASSERTIONS=On ../llvm-14.0.3.src -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=$(which g++) -DCMAKE_C_COMPILER=$(which gcc)
运行了两次这个命令,能跑下去了
解决gcc的问题后,cmake又报了个错
CMake Error at CMakeLists.txt:1256 (add_subdirectory):
add_subdirectory given source
"/opt/llvm-14.0.3.src/../third-party/benchmark" which is not an existing
directory.
https://github.com/llvm/llvm-project/issues/54941
从github上面看到,貌似是cmake的bug(也可能是feature hhhh)
解决方案:
vi CMakeCache.txt
LLVM_INCLUDE_BENCHMARKS:BOOL=OFF
终于跑通了,make中,希望下班前能装上bcc,折腾好几天了。。。