]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
build: Only probe for faster linker in dev build mode and on x86_64
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 30 Jul 2021 18:10:50 +0000 (20:10 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 31 Jul 2021 07:17:17 +0000 (09:17 +0200)
Using Gold or LLD on less common platforms such as MIPS may not be a
good idea (see e.g.
<https://www.sourceware.org/bugzilla/show_bug.cgi?id=22838>), so be
conservative and only probe for a faster linker on platforms that likely
don’t have toolchain bugs. Also, using a faster linker is in practice
only relevant for dev builds.

Fixes #907.

CMakeLists.txt
cmake/UseFastestLinker.cmake

index 2c6c4511a814949178ea4a19bebb94e6c5230153..4cf2e5f3e4effdcb096fed558364c75af0968b33 100644 (file)
@@ -66,9 +66,7 @@ endif()
 message(STATUS "Ccache dev mode: ${CCACHE_DEV_MODE}")
 
 include(UseCcache)
-if(NOT MSVC)
-  include(UseFastestLinker)
-endif()
+include(UseFastestLinker)
 include(StandardSettings)
 include(StandardWarnings)
 include(CIBuildType)
index ffc26ea29054074ae2f8b75c963543dce7db64de..9b4fdd6abe0a44061c2f2bf734d853bc69e26800 100644 (file)
@@ -1,3 +1,23 @@
+if(NOT CCACHE_DEV_MODE)
+  # For ccache, using a faster linker is in practice only relevant to reduce the
+  # compile-link-test cycle for developers, so use the standard linker for
+  # non-developer builds.
+  return()
+endif()
+
+if(MSVC)
+  message(STATUS "Using standard linker for MSVC")
+  return()
+endif()
+
+if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
+  # Be conservative and only probe for a faster linker on platforms that likely
+  # don't have toolchain bugs. See for example
+  # <https://www.sourceware.org/bugzilla/show_bug.cgi?id=22838>.
+  message(STATUS "Not probing for faster linker on ${CMAKE_SYSTEM_PROCESSOR}")
+  return()
+endif()
+
 function(check_linker linker)
   string(TOUPPER ${linker} upper_linker)
   file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/CMakefiles/CMakeTmp/main.c" "int main() { return 0; }")