Skip to content

Instantly share code, notes, and snippets.

@gglin001
Forked from unhammer/use_gold.sh
Created August 31, 2021 10:23
Show Gist options
  • Save gglin001/b9a6389533f31a94ae2d3e2c16c69651 to your computer and use it in GitHub Desktop.
Save gglin001/b9a6389533f31a94ae2d3e2c16c69651 to your computer and use it in GitHub Desktop.
Linking with lld on Ubuntu/Debian in CMake projects (or gold in automake projects)
sudo apt install binutils
cd ~/src/an_autotools_project
export CXXFLAGS='-fuse-ld=gold'
export CFLAGS='-fuse-ld=gold'
./configure
make -j4 # no longer wait for linking! =D
# gcc doesn't support -fuse-ld=lld http://gcc.gnu.org/ml/gcc-patches/2016-07/msg00145.html :(
sudo apt install lld-4.0
sudo ln -s /usr/bin/ld.lld-4.0 /usr/bin/ld.lld # Why doesn't Debian put this in /etc/alternatives by default?
cd ~/src/a_cmake_project
./cmake.sh -DCMAKE_C_FLAGS="-fuse-ld=lld" -DCMAKE_CXX_FLAGS="-fuse-ld=lld"
make -j4 # no longer wait for linking! =D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment