From c77db81616805936fa8471241b3b0fce4af12cec Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Wed, 3 Aug 2022 00:00:02 -0700 Subject: [PATCH] [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 --- llvm/runtimes/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt index 34fccca..d904121 100644 --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -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 -- 2.7.4