From 950cfca3abb5ba36505ed286f4ab2424bb2cb8f9 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Mon, 11 Mar 2019 09:48:48 -0400 Subject: [PATCH] enable lld linker if available --- cmake/checks/check_02_compiler_features.cmake | 28 +++++++++++++++---- doc/news/changes/minor/20190411TimoHeister | 3 ++ 2 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 doc/news/changes/minor/20190411TimoHeister diff --git a/cmake/checks/check_02_compiler_features.cmake b/cmake/checks/check_02_compiler_features.cmake index 7ac38fe19f..d108cc4767 100644 --- a/cmake/checks/check_02_compiler_features.cmake +++ b/cmake/checks/check_02_compiler_features.cmake @@ -420,19 +420,33 @@ RESET_CMAKE_REQUIRED() # -# Use the 'gold' linker if possible, given that it's substantially faster. +# Use 'lld' or the 'gold' linker if possible, given that either of them is +# substantially faster. # -# We have to try to link a full executable with -fuse-ld=gold to check -# whether "ld.gold" is actually available. +# We have to try to link a full executable with -fuse-ld=lld or -fuse-ld=gold +# to check whether "ld.lld" or "ld.gold" is actually available. # -# Clang always reports "argument unused during compilation" -# if "-fuse-ld=" is used, but fails at link time for an unsupported linker. +# Clang always reports "argument unused during compilation", but fails at link +# time for an unsupported linker. # # ICC also emits a warning but passes for unsupported linkers # unless we turn diagnostic warnings into errors. # # Wolfgang Bangerth, Matthias Maier, Daniel Arndt, 2015, 2018 # +IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wno-unused-command-line-argument") +ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") + ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-diag-error warn") +ENDIF() +ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror -fuse-ld=lld") +CHECK_CXX_SOURCE_COMPILES( + " + int main() { return 0; } + " + DEAL_II_COMPILER_HAS_FUSE_LD_LLD) +RESET_CMAKE_REQUIRED() + IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Wno-unused-command-line-argument") ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") @@ -446,7 +460,9 @@ CHECK_CXX_SOURCE_COMPILES( DEAL_II_COMPILER_HAS_FUSE_LD_GOLD) RESET_CMAKE_REQUIRED() -IF(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD) +IF(DEAL_II_COMPILER_HAS_FUSE_LD_LLD) + ADD_FLAGS(DEAL_II_LINKER_FLAGS "-fuse-ld=lld") +ELSEIF(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD) ADD_FLAGS(DEAL_II_LINKER_FLAGS "-fuse-ld=gold") ENDIF() diff --git a/doc/news/changes/minor/20190411TimoHeister b/doc/news/changes/minor/20190411TimoHeister new file mode 100644 index 0000000000..db6c9bdafb --- /dev/null +++ b/doc/news/changes/minor/20190411TimoHeister @@ -0,0 +1,3 @@ +New: If present, we will detect the LLD linker ld.lld at configuration time. +
+(Timo Heister, 2019/03/11) -- 2.39.5