[Bf-blender-cvs] [ca15ffb] master: CMake: use ld.gold linker when available

Campbell Barton noreply at git.blender.org
Sat May 2 14:15:08 CEST 2015


Commit: ca15ffb8ad8c25a18ac63eb096aa2c3aaaed7ea2
Author: Campbell Barton
Date:   Sat May 2 22:11:29 2015 +1000
Branches: master
https://developer.blender.org/rBca15ffb8ad8c25a18ac63eb096aa2c3aaaed7ea2

CMake: use ld.gold linker when available

Gives noticeable speedup linking blender

===================================================================

M	CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c7308e..44f6b2f 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")




More information about the Bf-blender-cvs mailing list