llvm 源码编译
升级前遇到的问题:
In file included from runqslower.bpf.c:3: .output/vmlinux.h:2:15: error: attribute 'preserve_access_index' is not supported by '#pragma clang attribute' #pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record) ^ .output/vmlinux.h:111541:15: error: '#pragma clang attribute pop' with no matching '#pragma clang attribute push' #pragma clang attribute pop
极速下载地址:https://toscode.gitee.com/mirrors/llvm-project.git
下载
git clone https://github.com/llvm/llvm-project.git cd llvm-project git checkout release/12.x
配置共享库及二进制路径
配置共享库: #cat /etc/ld.so.conf.d/llvm.conf /junqiang/llvm-12.x/lib64 生效方式: ldconfig 配置二进制路径: #cat /etc/profile | grep llvm export PATH=$PATH:/junqiang/llvm-12.x/bin 生效方式: source /etc/profile
编译:
# 编译llvm mkdir build cd build/ cmake .. -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_INCLUDE_DOCS=OFF -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EH=ON -DLLVM_INSTALL_UTILS=ON -DWITH_POLLY=ON -DLINK_POLLY_INTO_TOOLS=ON -DBUILD_SHARED_LIBS=ON -DLIBOMP_ENABLE_SHARED=ON -DLLVM_ENABLE_LIBCXX=ON -DLLDB_RELOCATABLE_PYTHON=ON -DLLVM_ENABLE_FFI=ON -DCMAKE_BUILD_TYPE=Release -DCLANG_DEFAULT_CXX_STDLIB=libc++ -DCLANG_INCLUDE_TESTS=OFF -DENABLE_LINKER_BUILD_ID=ON -DENABLE_X86_RELAX_RELOCATIONS=ON -DLIBCXXABI_INCLUDE_TESTS=OFF -DLIBCXX_INCLUDE_BENCHMARKS=OFF -DLIBCXX_INCLUDE_TESTS=OFF -DLIBOMP_TSAN_SUPPORT=ON -DLLDB_BUILD_INTEL_PT=OFF -DLLDB_INCLUDE_TESTS=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_GO_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON -DLLVM_TOOL_LLGO_BUILD=ON -DLLVM_TOOL_PARALLEL_LIBS_BUILD=ON -DLLVM_ENABLE_PIC=ON -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_PEDANTIC=ON -DLIBCXXABI_LIBDIR_SUFFIX=64 -DLIBCXX_LIBDIR_SUFFIX=64 -DLIBUNWIND_LIBDIR_SUFFIX=64 -DLLVM_LIBDIR_SUFFIX=64 -DCMAKE_INSTALL_PREFIX=/junqiang/llvm-12.x -DCMAKE_C_COMPILER=/usr/local/bin/gcc ../llvm/ make -j8 make install # 编译clang mkdir build cd build/ cmake .. -DLLVM_OPTIMIZED_TABLEGEN=ON -DLLVM_INCLUDE_DOCS=OFF -DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_EH=ON -DLLVM_INSTALL_UTILS=ON -DWITH_POLLY=ON -DLINK_POLLY_INTO_TOOLS=ON -DBUILD_SHARED_LIBS=ON -DLIBOMP_ENABLE_SHARED=ON -DLLVM_ENABLE_LIBCXX=ON -DLLDB_RELOCATABLE_PYTHON=ON -DLLVM_ENABLE_FFI=ON -DCMAKE_BUILD_TYPE=Release -DCLANG_DEFAULT_CXX_STDLIB=libc++ -DCLANG_INCLUDE_TESTS=OFF -DENABLE_LINKER_BUILD_ID=ON -DENABLE_X86_RELAX_RELOCATIONS=ON -DLIBCXXABI_INCLUDE_TESTS=OFF -DLIBCXX_INCLUDE_BENCHMARKS=OFF -DLIBCXX_INCLUDE_TESTS=OFF -DLIBOMP_TSAN_SUPPORT=ON -DLLDB_BUILD_INTEL_PT=OFF -DLLDB_INCLUDE_TESTS=OFF -DLLVM_ENABLE_OCAMLDOC=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_GO_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INSTALL_BINUTILS_SYMLINKS=ON -DLLVM_TOOL_LLGO_BUILD=ON -DLLVM_TOOL_PARALLEL_LIBS_BUILD=ON -DLLVM_ENABLE_PIC=ON -DLIBUNWIND_ENABLE_SHARED=OFF -DLIBCXX_ENABLE_PEDANTIC=ON -DLIBCXXABI_LIBDIR_SUFFIX=64 -DLIBCXX_LIBDIR_SUFFIX=64 -DLIBUNWIND_LIBDIR_SUFFIX=64 -DLLVM_LIBDIR_SUFFIX=64 -DCMAKE_INSTALL_PREFIX=/junqiang/llvm-12.x -DCMAKE_C_COMPILER=/usr/local/bin/gcc ../clang make -j8 make install