From a3fd3bfd15e31d9183dca8d892666aa3045a5019 Mon Sep 17 00:00:00 2001 From: Vladimir Chebotarev Date: Wed, 11 Dec 2019 13:04:51 +0300 Subject: [PATCH] Fixed linker searching logic. --- cmake/tools.cmake | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/cmake/tools.cmake b/cmake/tools.cmake index a97e7466286..025aac79b53 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -24,22 +24,22 @@ STRING(REGEX MATCHALL "[0-9]+" COMPILER_VERSION_LIST ${CMAKE_CXX_COMPILER_VERSIO LIST(GET COMPILER_VERSION_LIST 0 COMPILER_VERSION_MAJOR) option (LINKER_NAME "Linker name or full path") -find_program (LLD_PATH NAMES "ld.lld" "lld" "lld-${COMPILER_VERSION_MAJOR}") -find_program (GOLD_PATH NAMES "ld.gold" "gold") +if (COMPILER_GCC) + find_program (LLD_PATH NAMES "ld.lld") + find_program (GOLD_PATH NAMES "ld.gold") +else () + find_program (LLD_PATH NAMES "ld.lld-${COMPILER_VERSION_MAJOR}" "lld-${COMPILER_VERSION_MAJOR}" "ld.lld" "lld") + find_program (GOLD_PATH NAMES "ld.gold" "gold") +endif () # We prefer LLD linker over Gold or BFD. - if (NOT LINKER_NAME) if (LLD_PATH) - # GCC driver requires one of supported linker names like "lld". - # Clang driver simply allows full linker path. - if (COMPILER_GCC) - get_filename_component(LLD_BASENAME ${LLD_PATH} NAME) - if (LLD_BASENAME STREQUAL ld.lld) - set (LINKER_NAME "lld") - endif () + # GCC driver requires one of supported linker names like "lld". + set (LINKER_NAME "lld") else () + # Clang driver simply allows full linker path. set (LINKER_NAME ${LLD_PATH}) endif () endif () @@ -48,10 +48,7 @@ endif () if (NOT LINKER_NAME) if (GOLD_PATH) if (COMPILER_GCC) - get_filename_component(GOLD_BASENAME ${GOLD_PATH} NAME) - if (GOLD_BASENAME STREQUAL ld.gold) - set (LINKER_NAME "gold") - endif () + set (LINKER_NAME "gold") else () set (LINKER_NAME ${GOLD_PATH}) endif ()