[PATCH] D142106: [runtimes build] Pass on RUNTIMES_<target>_... options when using runtime_default_target
David Spickett via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 19 05:49:33 PST 2023
DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When configuring with the following:
cmake -S "/home/david.spickett/llvm-project/llvm" -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind" \
-DLLVM_USE_LINKER=lld \
-DRUNTIMES_armv8l-unknown-linux-gnueabihf_COMPILER_RT_BUILD_GWP_ASAN=OFF
Prior to this patch BUILD_GWP_ASAN was not passed down to compiler-rt.
If you configured in a different way you would go through runtime_register_target
which does have logic to convert RUNTIMES_<target>_<setting> into just
<setting> to be passed to the sub project normally.
builtin_register_target also does this so I've lifted the code from that
into a function and use that in builtin_register_target and runtime_default_target.
runtime_register_target also handles "name" and "target" being different,
so I have left that as is.
Depends on D139536 <https://reviews.llvm.org/D139536>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D142106
Files:
llvm/runtimes/CMakeLists.txt
Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ 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}_<runtimes cmake option>
+# 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
@@ -199,7 +214,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)
@@ -225,6 +240,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
@@ -242,6 +259,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}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142106.490477.patch
Type: text/x-patch
Size: 2834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230119/63d2bb83/attachment.bin>
More information about the llvm-commits
mailing list