summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2023-10-16 09:42:03 (GMT)
committerBrad King <brad.king@kitware.com>2023-10-24 12:36:43 (GMT)
commit538ff514b5e3ce9275728df78e78167d54b87cdb (patch)
tree42ff7f739f66843d8abd9b6d4e316eabd1ad4ffe /Modules/Compiler
parentc26c6ac488468e61c7b58226325043201c80c43e (diff)
downloadCMake-538ff514b5e3ce9275728df78e78167d54b87cdb.zip
CMake-538ff514b5e3ce9275728df78e78167d54b87cdb.tar.gz
CMake-538ff514b5e3ce9275728df78e78167d54b87cdb.tar.bz2
Link Step: use the correct linker for depfile handling
Follow up commit 375e6fdbbe (Link step: use linker dependency linker file, 2023-04-19, v3.27.0-rc1~126^2).
Diffstat (limited to 'Modules/Compiler')
-rw-r--r--Modules/Compiler/GNU.cmake29
1 files changed, 18 insertions, 11 deletions
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index d01054b..9be7c32 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -74,15 +74,19 @@ macro(__compiler_gnu lang)
if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
## check if this feature is supported by the linker
- execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -Wl,--help
- OUTPUT_VARIABLE _linker_capabilities
- ERROR_VARIABLE _linker_capabilities)
- if(_linker_capabilities MATCHES "--dependency-file")
- set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED TRUE)
+ if (CMAKE_${lang}_COMPILER_LINKER AND CMAKE_${lang}_COMPILER_LINKER_ID MATCHES "GNU|LLD")
+ execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --help
+ OUTPUT_VARIABLE _linker_capabilities
+ ERROR_VARIABLE _linker_capabilities)
+ if(_linker_capabilities MATCHES "--dependency-file")
+ set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED TRUE)
+ else()
+ set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE)
+ endif()
+ unset(_linker_capabilities)
else()
set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE)
endif()
- unset(_linker_capabilities)
endif()
endif()
if (CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
@@ -91,11 +95,14 @@ macro(__compiler_gnu lang)
unset(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER)
endif()
- # For now, due to GNU binutils ld bug when LTO is enabled (see GNU bug
- # `30568 <https://sourceware.org/bugzilla/show_bug.cgi?id=30568>`_),
- # deactivate this feature.
- if (NOT DEFINED CMAKE_LINK_DEPENDS_USE_LINKER)
- set(CMAKE_LINK_DEPENDS_USE_LINKER FALSE)
+ # Due to GNU binutils ld bug when LTO is enabled (see GNU bug
+ # `30568 <https://sourceware.org/bugzilla/show_bug.cgi?id=30568>`_),
+ # deactivate this feature if the version is less than 2.41.
+ # For now, all known versions of gold linker have also this bug.
+ if (CMAKE_${lang}_COMPILER_LINKER_ID STREQUAL "GNUgold"
+ OR (CMAKE_${lang}_COMPILER_LINKER_ID STREQUAL "GNU"
+ AND CMAKE_${lang}_COMPILER_LINKER_VERSION VERSION_LESS "2.41"))
+ set(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER FALSE)
endif()
# Initial configuration flags.