From 6604061a09651f22a7d86b085c59e820d9c3f544 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Sun, 6 Sep 2015 16:46:50 -0500 Subject: [PATCH] CMake: Refactor check for -fuse-ld=gold into check_01_compiler_features.cmake --- cmake/checks/check_01_compiler_features.cmake | 24 +++++++++++++++++++ cmake/setup_compiler_flags_gnu.cmake | 5 ---- cmake/setup_compiler_flags_intel.cmake | 5 ---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/cmake/checks/check_01_compiler_features.cmake b/cmake/checks/check_01_compiler_features.cmake index 52b885223e..d26a2f21e1 100644 --- a/cmake/checks/check_01_compiler_features.cmake +++ b/cmake/checks/check_01_compiler_features.cmake @@ -32,6 +32,7 @@ # DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED # DEAL_II_DEPRECATED # DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA +# DEAL_II_COMPILER_HAS_FUSE_LD_GOLD # @@ -336,3 +337,26 @@ CHECK_CXX_SOURCE_COMPILES( DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA) RESET_CMAKE_REQUIRED() + +# +# Use the 'gold' linker if possible, given that it's substantially faster. +# +# We have to try to link a full executable with -fuse-ld=gold to check +# whether "ld.gold" is actually available. gcc has the bad habit of +# accepting the flag without emitting an error. +# +# Wolfgang Bangerth, Matthias Maier, 2015 +# +PUSH_CMAKE_REQUIRED("-Werror") +PUSH_CMAKE_REQUIRED("-fuse-ld=gold") +CHECK_CXX_SOURCE_COMPILES( + " + int main() { return 0; } + " + DEAL_II_COMPILER_HAS_FUSE_LD_GOLD) +RESET_CMAKE_REQUIRED() + +IF(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD) + ADD_FLAGS(DEAL_II_LINKER_FLAGS "-fuse-ld=gold") +ENDIF() + diff --git a/cmake/setup_compiler_flags_gnu.cmake b/cmake/setup_compiler_flags_gnu.cmake index e43680ccbf..9409c36cc8 100644 --- a/cmake/setup_compiler_flags_gnu.cmake +++ b/cmake/setup_compiler_flags_gnu.cmake @@ -54,11 +54,6 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic") # ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed") -# -# Use the 'gold' linker if possible, given that it's substantially faster. -# -ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-fuse-ld=gold") - # # Setup various warnings: # diff --git a/cmake/setup_compiler_flags_intel.cmake b/cmake/setup_compiler_flags_intel.cmake index 62b3c9e6b8..2232a64d03 100644 --- a/cmake/setup_compiler_flags_intel.cmake +++ b/cmake/setup_compiler_flags_intel.cmake @@ -45,11 +45,6 @@ ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS "-fpic") # ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--as-needed") -# -# Use the 'gold' linker if possible, given that it's substantially faster. -# -ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS "-fuse-ld=gold") - # # Set ansi mode: # -- 2.39.5