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).
This commit is contained in:
Marc Chevrier
2023-10-16 11:42:03 +02:00
committed by Brad King
parent c26c6ac488
commit 538ff514b5

View File

@@ -74,15 +74,19 @@ macro(__compiler_gnu lang)
if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
## check if this feature is supported by the linker ## check if this feature is supported by the linker
execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -Wl,--help if (CMAKE_${lang}_COMPILER_LINKER AND CMAKE_${lang}_COMPILER_LINKER_ID MATCHES "GNU|LLD")
OUTPUT_VARIABLE _linker_capabilities execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" --help
ERROR_VARIABLE _linker_capabilities) OUTPUT_VARIABLE _linker_capabilities
if(_linker_capabilities MATCHES "--dependency-file") ERROR_VARIABLE _linker_capabilities)
set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED TRUE) 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() else()
set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE) set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE)
endif() endif()
unset(_linker_capabilities)
endif() endif()
endif() endif()
if (CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) if (CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED)
@@ -91,11 +95,14 @@ macro(__compiler_gnu lang)
unset(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER) unset(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER)
endif() endif()
# For now, due to GNU binutils ld bug when LTO is enabled (see GNU bug # Due to GNU binutils ld bug when LTO is enabled (see GNU bug
# `30568 <https://sourceware.org/bugzilla/show_bug.cgi?id=30568>`_), # `30568 <https://sourceware.org/bugzilla/show_bug.cgi?id=30568>`_),
# deactivate this feature. # deactivate this feature if the version is less than 2.41.
if (NOT DEFINED CMAKE_LINK_DEPENDS_USE_LINKER) # For now, all known versions of gold linker have also this bug.
set(CMAKE_LINK_DEPENDS_USE_LINKER FALSE) 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() endif()
# Initial configuration flags. # Initial configuration flags.