Merge pull request #8139 from excitoon-favorites/better-linking

Fixed linker searching logic
This commit is contained in:
alesapin 2019-12-11 16:58:33 +03:00 committed by GitHub
commit 08d59890ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
# GCC driver requires one of supported linker names like "lld".
set (LINKER_NAME "lld")
endif ()
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 ()
else ()
set (LINKER_NAME ${GOLD_PATH})
endif ()