aboutsummaryrefslogtreecommitdiff
path: root/cmake/platform/unix
diff options
context:
space:
mode:
authorCarbenium <carbenium@outlook.com>2020-07-24 19:00:44 +0200
committerShauren <shauren.trinity@gmail.com>2022-01-23 23:07:56 +0100
commitb336ed89961c25ff39317b1f57e8aa4a70a0994c (patch)
tree77448b70ca9470e189f884619a2c6748c8877f60 /cmake/platform/unix
parent10f835b058ffa517866b08efe6634b0d5226bb66 (diff)
Build: Add WITH_LD_GOLD option to use gold linker on unix
gold is an ELF-only linker which has a better performance than the default ld. (cherry picked from commit 796e2b32e03e7b1a56e44bd4b8988f9156bbb026)
Diffstat (limited to 'cmake/platform/unix')
-rw-r--r--cmake/platform/unix/settings.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/platform/unix/settings.cmake b/cmake/platform/unix/settings.cmake
index 51e0955977f..e86a14944bc 100644
--- a/cmake/platform/unix/settings.cmake
+++ b/cmake/platform/unix/settings.cmake
@@ -18,6 +18,19 @@ add_custom_target(uninstall
)
message(STATUS "UNIX: Created uninstall target")
+if(USE_LD_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_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fuse-ld=gold")
+ message(STATUS "UNIX: Using GNU gold linker")
+ else()
+ message(WARNING "UNIX: GNU gold linker isn't available, using the default system linker")
+ endif()
+else()
+ message(STATUS "UNIX: Using default system linker")
+endif()
+
message(STATUS "UNIX: Detected compiler: ${CMAKE_C_COMPILER}")
if(CMAKE_C_COMPILER MATCHES "gcc" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake)