Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better linking #8115

Merged
merged 3 commits into from
Dec 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 26 additions & 3 deletions cmake/tools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,34 @@ 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")

# We prefer LLD linker over Gold or BFD.

if (NOT LINKER_NAME)
if (LLD_PATH)
set (LINKER_NAME "lld")
elseif (GOLD_PATH)
set (LINKER_NAME "gold")
# GCC driver requires one of supported linker names like "lld".
# Clang driver simply allows full linker path.

if (COMPILER_GCC)
get_filename_component(LLD_BASE_NAME ${LLD_PATH} NAME)
if (LLD_BASE_NAME STREQUAL ld.lld)
set (LINKER_NAME "lld")
endif ()
else ()
set (LINKER_NAME ${LLD_PATH})
endif ()
endif ()
endif ()

if (NOT LINKER_NAME)
if (GOLD_PATH)
if (COMPILER_GCC)
get_filename_component(GOLD_BASE_NAME ${GOLD_PATH} NAME)
if (GOLD_BASE_NAME STREQUAL ld.gold)
set (LINKER_NAME "gold")
endif ()
else ()
set (LINKER_NAME ${GOLD_PATH})
endif ()
endif ()
endif ()

Expand Down