[Bf-blender-cvs] [83ebf50] master: CMake: Make ld.gold linker optional

Sergey Sharybin noreply at git.blender.org
Wed Nov 2 10:43:36 CET 2016


Commit: 83ebf501cdfdb21a8b111dcaf32481bc021094f0
Author: Sergey Sharybin
Date:   Wed Nov 2 10:42:15 2016 +0100
Branches: master
https://developer.blender.org/rB83ebf501cdfdb21a8b111dcaf32481bc021094f0

CMake: Make ld.gold linker optional

Some platforms are having hard time using this linker so added an option
to not use it. The options is an advanced one and enabled by default so
should not cause any changes for current users.

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

M	CMakeLists.txt
M	build_files/cmake/platform/platform_unix.cmake

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe226dd..bbab208 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -508,6 +508,12 @@ mark_as_advanced(WITH_C11)
 option(WITH_CXX11 "Build with C++11 standard enabled, for development use only!" ${_cxx11_init})
 mark_as_advanced(WITH_CXX11)
 
+# Compiler toolchain
+if(CMAKE_COMPILER_IS_GNUCC)
+	option(WITH_LINKER_GOLD "Use ld.gold linker which is usually faster than ld.bfd" ON)
+	mark_as_advanced(WITH_LINKER_GOLD)
+endif()
+
 # Dependency graph
 option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
 mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
diff --git a/build_files/cmake/platform/platform_unix.cmake b/build_files/cmake/platform/platform_unix.cmake
index e33141f..62e0caa 100644
--- a/build_files/cmake/platform/platform_unix.cmake
+++ b/build_files/cmake/platform/platform_unix.cmake
@@ -384,17 +384,18 @@ add_definitions(-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
 if(CMAKE_COMPILER_IS_GNUCC)
 	set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
 
-	# 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(STATUS "GNU gold linker isn't available, using the default system linker.")
+	if(WITH_LINKER_GOLD)
+		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(STATUS "GNU gold linker isn't available, using the default system linker.")
+		endif()
+		unset(LD_VERSION)
 	endif()
-	unset(LD_VERSION)
 
 # CLang is the same as GCC for now.
 elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")




More information about the Bf-blender-cvs mailing list