diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -96,20 +96,35 @@ ${EXTRA_ARGS}) endfunction() -function(builtin_register_target compiler_rt_path target) - cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN}) - - check_apple_target(${target} builtin) - +# Find variables with names of the form: +# ${kind}_${target}_ +# Rename them so they can be passed directly to the runtime or builtins that +# they apply to. +# +# For example: +# RUNTIMES_armv8l-unknown-linux-gnueabihf_COMPILER_RT_BUILD_GWP_ASAN=OFF +# Would be changed to: +# COMPILER_RT_BUILD_GWP_ASAN=OFF +# So it can be passed directly to compiler-rt. +function (get_extra_cmake_args kind target) get_cmake_property(variableNames VARIABLES) foreach(variableName ${variableNames}) - string(FIND "${variableName}" "BUILTINS_${target}" out) + string(FIND "${variableName}" "${kind}_${target}" out) if("${out}" EQUAL 0) - string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName}) + string(REPLACE "${kind}_${target}_" "" new_name ${variableName}) string(REPLACE ";" "|" new_value "${${variableName}}") list(APPEND ${target}_extra_args "-D${new_name}=${new_value}") endif() endforeach() + set(${target}_extra_args ${${target}_extra_args} PARENT_SCOPE) +endfunction() + +function(builtin_register_target compiler_rt_path target) + cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN}) + + check_apple_target(${target} builtin) + + get_extra_cmake_args("BUILTINS" ${target}) llvm_ExternalProject_Add(builtins-${target} ${compiler_rt_path}/lib/builtins @@ -193,7 +208,7 @@ endforeach() function(runtime_default_target) - cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES" ${ARGN}) + cmake_parse_arguments(ARG "" "" "DEPENDS;PREFIXES;CMAKE_ARGS" ${ARGN}) include(${LLVM_BINARY_DIR}/runtimes/Components.cmake OPTIONAL) set(SUB_CHECK_TARGETS ${SUB_CHECK_TARGETS} PARENT_SCOPE) @@ -219,6 +234,8 @@ list(APPEND test_targets runtimes-test-depends check-runtimes) endif() + get_extra_cmake_args("RUNTIMES" ${LLVM_TARGET_TRIPLE}) + set_enable_per_target_runtime_dir() llvm_ExternalProject_Add(runtimes @@ -236,6 +253,7 @@ -DCMAKE_ASM_COMPILER_WORKS=ON ${COMMON_CMAKE_ARGS} ${RUNTIMES_CMAKE_ARGS} + ${${LLVM_TARGET_TRIPLE}_extra_args} PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES LLVM_USE_LINKER ${ARG_PREFIXES}