LLVM 源码下载及编译

代码同步

llvm github 仓库地址为

https://github.com/llvm/llvm-project.git​github.com/llvm/llvm-project.git

git clone 到本地即可

编译并安装

  • 编译安装llvm
cd llvm-project

mkdir build

cd build

cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE="Release" ../llvm

make

make install
  • 编译安装Clang
cd llvm-project

mkdir clang_build

cd clang_build

cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE="Release" ../clang

make

make install
  • 编译compiler-rt
cd llvm-project

mkdir build-compiler-rt

cd build-compiler-rt

cmake ../compiler-rt -DLLVM_CONFIG_PATH=../build/bin/llvm-config

make

自己遇到的问题及解决办法:

[100%] Built target BugpointPasses
[100%] Built target opt
[100%] Built target dsymutil
/tmp/ccg2CWXk.s: Assembler messages:
/tmp/ccg2CWXk.s:5085: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/ccg2CWXk.s:5851: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
/tmp/ccg2CWXk.s:5901: Error: symbol `_ZN4llvm12function_refIFvvEE11callback_fnIUlvE2_EEvl' is already defined
tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/build.make:120: recipe for target 'tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o' failed
make[2]: *** [tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/ELFDumper.cpp.o] Error 1
CMakeFiles/Makefile2:21548: recipe for target 'tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/all' failed
make[1]: *** [tools/llvm-readobj/CMakeFiles/llvm-readobj.dir/all] Error 2
Makefile:170: recipe for target 'all' failed
make: *** [all] Error 2

解决方法:

按照网站修改一下 llvm/tools/llvm-readobj/ELFDumper.cpp文件,然后重新make

上一篇:八大排序算法


下一篇:2021/12/7 HttpOnly绕过,xss-labs