[CMake] Fix runtimes cross-compilation when using LLVM_USE_LINKER

This is motivated by https://reviews.llvm.org/D115852#3226050 where passing
`LLVM_USE_LINKER` in PASSTHROUGH_PREFIXES breaks cross-compilation
(e.g. targeting Windows on a Linux host). As suggested on that diff, implement
an override for it by allowing users to pass `RUNTIMES_${target}_LLVM_USE_LINKER`
to specify the linker for runtimes. Defaults to host linker if not specified.

Reviewed By: phosek, smeenai

Differential Revision: https://reviews.llvm.org/D131051
This commit is contained in:
Vincent Lee 2022-08-03 00:00:02 -07:00
parent a5a8a05c78
commit c77db81616
1 changed files with 4 additions and 1 deletions

View File

@ -346,6 +346,10 @@ function(runtime_register_target name target)
list(APPEND ${name}_extra_args -DLLVM_ENABLE_RUNTIMES=${LLVM_ENABLE_RUNTIMES_PASSTHROUGH})
endif()
if(NOT RUNTIMES_${name}_LLVM_USE_LINKER AND NOT RUNTIMES_${target}_LLVM_USE_LINKER)
list(APPEND ${name}_extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER})
endif()
llvm_ExternalProject_Add(runtimes-${name}
${CMAKE_CURRENT_SOURCE_DIR}/../../runtimes
DEPENDS ${${name}_deps}
@ -362,7 +366,6 @@ function(runtime_register_target name target)
-DLLVM_RUNTIMES_TARGET=${name}
${COMMON_CMAKE_ARGS}
${${name}_extra_args}
PASSTHROUGH_PREFIXES LLVM_USE_LINKER
EXTRA_TARGETS ${${name}_extra_targets}
${${name}_test_targets}
USE_TOOLCHAIN