CMake: Use lld when using Clang compiler
When using the `WITH_LINKER_LLD` option, the logic to find the `ld.lld` binary and actually tell the build system to use it was specific to GCC. I've copied the Clang-specific logic for Mold and adjusted it to find LLD. Not entirely sure why this is necessary, as LLD is actually Clang's linker. However, without this change, CMake would use regular old slow `ld` to link. Pull Request: https://projects.blender.org/blender/blender/pulls/108884
This commit is contained in:
parent
4a0468c1ed
commit
8c8e1ebdd2
@ -928,6 +928,27 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
unset(MOLD_BIN)
|
||||
endif()
|
||||
|
||||
if(WITH_LINKER_LLD AND _IS_LINKER_DEFAULT)
|
||||
find_program(LLD_BIN "ld.lld")
|
||||
mark_as_advanced(LLD_BIN)
|
||||
if(NOT LLD_BIN)
|
||||
message(STATUS "The \"ld.lld\" binary could not be found, using system linker.")
|
||||
set(WITH_LINKER_LLD OFF)
|
||||
else()
|
||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0)
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " --ld-path=\"${LLD_BIN}\"")
|
||||
string(APPEND CMAKE_SHARED_LINKER_FLAGS " --ld-path=\"${LLD_BIN}\"")
|
||||
string(APPEND CMAKE_MODULE_LINKER_FLAGS " --ld-path=\"${LLD_BIN}\"")
|
||||
else()
|
||||
string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=\"${LLD_BIN}\"")
|
||||
string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=\"${LLD_BIN}\"")
|
||||
string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=\"${LLD_BIN}\"")
|
||||
endif()
|
||||
set(_IS_LINKER_DEFAULT OFF)
|
||||
endif()
|
||||
unset(LLD_BIN)
|
||||
endif()
|
||||
|
||||
# Intel C++ Compiler
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||
# think these next two are broken
|
||||
|
Loading…
Reference in New Issue
Block a user