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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM