From ca15ffb8ad8c25a18ac63eb096aa2c3aaaed7ea2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 May 2015 22:11:29 +1000 Subject: [PATCH] CMake: use ld.gold linker when available Gives noticeable speedup linking blender --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c7308e1fc2..44f6b2f8752 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1162,6 +1162,19 @@ if(UNIX AND NOT APPLE) # though some c11 features can still be used. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu89") endif() + + # use ld.gold linker if available, could make optional + execute_process( + COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version + ERROR_QUIET OUTPUT_VARIABLE LD_VERSION) + if ("${LD_VERSION}" MATCHES "GNU gold") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold") + else () + message(WARNING "GNU gold linker isn't available, using the default system linker.") + endif () + unset(LD_VERSION) + # CLang is the same as GCC for now. elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")