Don't use gold linker if mold linker is provided (#15746)

This commit is contained in:
Maxim Kurin 2023-02-21 06:57:41 +00:00 committed by GitHub
parent 7f3f576151
commit f347968a1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -501,6 +501,11 @@ endfunction()
# Tries to use gold linker in current scope (directory, function)
#
function(ov_try_use_gold_linker)
# don't use the gold linker, if the mold linker is set
if(CMAKE_EXE_LINKER_FLAGS MATCHES "mold" OR CMAKE_MODULE_LINKER_FLAGS MATCHES "mold" OR CMAKE_SHARED_LINKER_FLAGS MATCHES "mold")
return()
endif()
# gold linker on ubuntu20.04 may fail to link binaries build with sanitizer
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_SANITIZER AND NOT CMAKE_CROSSCOMPILING)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold" PARENT_SCOPE)