代碼同步
llvm github 倉庫地址為
https://github.com/llvm/llvm-project.gitgithub.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
