Index: cmake/config-ix.cmake =================================================================== --- cmake/config-ix.cmake +++ cmake/config-ix.cmake @@ -548,8 +548,19 @@ set(LLVM_BINUTILS_INCDIR "" CACHE PATH "PATH to binutils/include containing plugin-api.h for gold plugin.") -if(APPLE) - find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker") +if(CMAKE_HOST_APPLE AND APPLE) + if(CMAKE_XCRUN) + execute_process(COMMAND ${CMAKE_XCRUN} -find ld + OUTPUT_VARIABLE LD64_EXECUTABLE + OUTPUT_STRIP_TRAILING_WHITESPACE) + else() + find_program(LD64_EXECUTABLE NAMES ld DOC "The ld64 linker") + endif() + + if(LD64_EXECUTABLE) + set(LD64_EXECUTABLE ${LD64_EXECUTABLE} CACHE PATH "ld64 executable") + message(STATUS "Found ld64 - ${LD64_EXECUTABLE}") + endif() endif() include(FindOCaml)