llvm gold build

Binutils Building

Download binutils source code

1
git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils

Build binutils

1
2
3
4
mkdir build
cd build
../binutils/configure --enable-gold --enable-plugins --disable-werror
sudo make install

LLVMgold.so build

Download LLVM source code

1
https://github.com/llvm-mirror/llvm.git

Build LLVM with gold-plugin

1
2
3
4
mkdir build
cd build
cmake ../llvm -DLLVM_BINUTILS_INCDIR="path/to/binutils/include"
make -j($nproc)

And the LLVMgold.so will appear in the lib folder.

Copy

1
2
3
4
sudo cp lib/LLVMgold.so /usr/local/lib
sudo mkdir /usr/lib/bfd-plugins
sudo cp lib/LLVMgold.so /usr/lib/bfd-plugins
sudo cp lib/libLTO.so /usr/lib/bfd-plugins