diff options
author | Campbell Barton <campbell@blender.org> | 2022-01-12 05:35:07 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-01-14 01:44:58 +0300 |
commit | 8b3d798374a2c6b5026791e8ef5ce4fe6494f801 (patch) | |
tree | 63c5e1bd9e13fbe7d196a05c2cefa3802fe1417b /CMakeLists.txt | |
parent | 0c5ccae79d62127106af589f2d732cf40aa5213a (diff) |
CMake: add WITH_LINKER_MOLD option for GCC/Clang Unix platforms
Can give considerably faster linking, especially on system with many
cores.
The mold linker recently reached 1.0, see:
https://github.com/rui314/mold
The current stable release of GCC can't use this linker via
-fuse-ld=mold, so this patch uses the "-B" argument to add a binary
directory containing an alternate "ld" command that points to
"mold" (which is part of the default mold installation).
Some timing tests for linking full builds for AMD TR 3970X:
- BFD: 20.78 seconds.
- LLD: 12.16 seconds.
- GOLD: 7.21 seconds.
- MOLD: 2.53 seconds.
Ref D13807
Reviewed by: sergey, brecht
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 88c71899f8e..5d796a5c140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,6 +567,10 @@ if(UNIX AND NOT APPLE) option(WITH_LINKER_LLD "Use ld.lld linker which is usually faster than ld.gold" OFF) mark_as_advanced(WITH_LINKER_LLD) endif() + if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") + option(WITH_LINKER_MOLD "Use ld.mold linker which is usually faster than ld.gold & ld.lld." OFF) + mark_as_advanced(WITH_LINKER_MOLD) + endif() endif() option(WITH_COMPILER_ASAN "Build and link against address sanitizer (only for Debug & RelWithDebInfo targets)." OFF) |