做我展示clang-cfi机制的项目。因此,需要 LLVM 黄金插件。根据帖子的描述,当我在执行第 6 步时,在输入 make -j8 后(这里我也尝试使用 make -j1、-j2、-j4),它总是告诉我以下错误:无法分配记忆。我已经将 ubuntu 的基本内存设置为最大值,不能再增加了。 错误信息
https://github.com/SVF-tools/SVF/wiki/Install-LLVM-Gold-Plugin-on-Ubuntu
1. Library requirements
sudo apt-get install linux-headers-$(uname -r) git g++ gcc cmake bash csh gawk automake libtool bison flex libncurses5-dev
Check 'makeinfo -v'. If 'makeinfo' does not exist
sudo apt-get install apt-file texinfo texi2html
sudo apt-file update
sudo apt-file search makeinfo
2. Download binutils source code
cd ~
git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils
3. Build binutils
mkdir build
cd build
../binutils/configure --enable-gold --enable-plugins --disable-werror
make
4. Download LLVM-6.0.0, clang-6.0.0. Unzip the LLVM and Clang source files
cd ~
tar xf llvm-6.0.0.tar.xz
tar xf cfe-6.0.0.tar.xz
mv cfe-6.0.0.src llvm-6.0.0.src/tools/clang
5. Modify gold-plugin.cpp to make clang generate bitcode
vi llvm-6.0.0.src/tools/gold/gold-plugin.cpp
add a new line between line 257 and 258: "TheOutputType = OT_SAVE_TEMPS;"
6. Build LLVM with gold-plugin
mkdir llvm-6.0.0.obj
cd llvm-6.0.0.obj
cmake ../llvm-6.0.0.src -DLLVM_BINUTILS_INCDIR="PATH_TO_binutils_SRC/include"
(or "cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../llvm-6.0.0.src -DLLVM_BINUTILS_INCDIR="PATH_TO_binutils_SRC/include"" for debug version)
make -j8
7. Backup ar, nm, ld and ranlib
cd ~
mkdir backup
cd /usr/bin/
cp ar ~/backup/
cp nm ~/backup/
cp ld ~/backup/
cp ranlib ~/backup/
8. Replace ar, nm, ld and ranlib
cd /usr/bin/
sudo cp ~/build/binutils/ar ./
sudo rm nm
sudo cp ~/build/binutils/nm-new ./nm
sudo cp ~/build/binutils/ranlib ./
sudo cp ~/build/gold/ld-new ./ld
9. install LLVMgold.so to /usr/lib/bfd-plugins
cd /usr/lib
sudo mkdir bfd-plugins
cd bfd-plugins
sudo cp ~/llvm-6.0.0.obj/lib/LLVMgold.so ./
sudo cp ~/llvm-6.0.0.obj/lib/libLTO.* ./
10. export environment variables
export CC="~/llvm-6.0.0.obj/bin/clang -flto -g"
export CXX="~/llvm-6.0.0.obj/bin/clang++ -flto -g"
export RANLIB=/bin/true
谁能告诉我如何解决这个问题?非常感谢你。