CMake: use ld.gold linker when available

Gives noticeable speedup linking blender
This commit is contained in:
Campbell Barton 2015-05-02 22:11:29 +10:00
parent 929c9de3dc
commit ca15ffb8ad
1 changed files with 13 additions and 0 deletions

View File

@ -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")