Skip to content

Instantly share code, notes, and snippets.

@unhammer
Last active June 3, 2022 02:31
Show Gist options
  • Save unhammer/41f2e89a6b9ba36fbe8992315ae860e7 to your computer and use it in GitHub Desktop.
Save unhammer/41f2e89a6b9ba36fbe8992315ae860e7 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