Skip to content

Commit

Permalink
[fold] handle case where both mold and gold are installed
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed Nov 7, 2023
1 parent 9d546e1 commit 1fa6ebf
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions Builds/CMake/RippledCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,19 @@ else ()
>)
endif ()

if (use_gold AND is_gcc)
if (use_mold)
# use mold linker if available
execute_process (
COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=mold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "mold")
set(found_nondefault_linker TRUE)
target_link_libraries (common INTERFACE -fuse-ld=mold)
endif ()
unset (LD_VERSION)
endif ()

if (use_gold AND is_gcc AND (not found_non_default_linker))
# use gold linker if available
execute_process (
COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=gold -Wl,--version
Expand All @@ -150,6 +162,7 @@ if (use_gold AND is_gcc)
required to make gold play nicely with jemalloc.
#]=========================================================]
if (("${LD_VERSION}" MATCHES "GNU gold") AND (NOT jemalloc))
set(found_nondefault_linker TRUE)
target_link_libraries (common
INTERFACE
-fuse-ld=gold
Expand All @@ -165,7 +178,7 @@ if (use_gold AND is_gcc)
unset (LD_VERSION)
endif ()

if (use_lld)
if (use_lld AND (not found_nondefault_linker))
# use lld linker if available
execute_process (
COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=lld -Wl,--version
Expand All @@ -176,16 +189,6 @@ if (use_lld)
unset (LD_VERSION)
endif()

if (use_mold AND is_gcc)
# use mold linker if available
execute_process (
COMMAND ${CMAKE_CXX_COMPILER} -fuse-ld=mold -Wl,--version
ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "mold")
target_link_libraries (common INTERFACE -fuse-ld=mold)
endif ()
unset (LD_VERSION)
endif ()

if (assert)
foreach (var_ CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE)
Expand Down

0 comments on commit 1fa6ebf

Please sign in to comment.