Doing my project of displaying clang-cfi mechanism. Therefore, the LLVM gold-plugin is needed. According to the description from a post, when I was doing the 6 step, after I typed make -j8 (here I also try with make -j1, -j2, -j4), it always tell me the below error: cannot allocate the memory. I already set my base memory of ubuntu to the maximum value and it can not be increased more. error message
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
The base memory and disk space of my ubuntu is allocated as pic
Can anybody tell me how to solve this problem? Thank you sooooooooooooooo much.