[PATCH] D145683: [runtimes] Allow passing individual parameters to the default target runtimes/builtins

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 9 03:47:03 PST 2023


mstorsjo created this revision.
mstorsjo added a reviewer: phosek.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

Currently, one can pass extra parameters to builds of runtimes
for specific targets, by setting them as e.g.
RUNTIMES_<targetname>_CMAKE_CXX_FLAGS. When not setting
LLVM_RUNTIME_TARGETS (or when it is set to "default"), no flags
are propagated in this way, but one can pass a set of cmake flags
to set via RUNTIMES_CMAKE_ARGS though.

While RUNTIMES_CMAKE_ARGS gives almost the same abilities, it's
slightly more cumbersome less obvious. (This flag is only available
for the runtimes, but not for the builtins.)

Thus, in addition to that existing flag, allow using the same pattern
of prefixing variables with "RUNTIMES_<targetname>_" and
"BUILTINS_<targetname>_", with targetname set to "default".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145683

Files:
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -77,6 +77,16 @@
 
   set_enable_per_target_runtime_dir()
 
+  get_cmake_property(variableNames VARIABLES)
+  foreach(variableName ${variableNames})
+    string(FIND "${variableName}" "BUILTINS_default" out)
+    if("${out}" EQUAL 0)
+      string(REPLACE "BUILTINS_default_" "" new_name ${variableName})
+      string(REPLACE ";" "|" new_value "${${variableName}}")
+      list(APPEND default_target_extra_args "-D${new_name}=${new_value}")
+    endif()
+  endforeach()
+
   llvm_ExternalProject_Add(builtins
                            ${compiler_rt_path}/lib/builtins
                            DEPENDS ${ARG_DEPENDS}
@@ -88,6 +98,7 @@
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
                                       ${COMMON_CMAKE_ARGS}
                                       ${BUILTINS_CMAKE_ARGS}
+                                      ${default_target_extra_args}
                            PASSTHROUGH_PREFIXES COMPILER_RT
                                                 DARWIN
                                                 SANITIZER
@@ -214,6 +225,17 @@
     endif()
   endforeach()
 
+  set(default_target_extra_args ${ARG_CMAKE_ARGS})
+  get_cmake_property(variableNames VARIABLES)
+  foreach(variableName ${variableNames})
+    string(FIND "${variableName}" "RUNTIMES_default_" out)
+    if("${out}" EQUAL 0)
+      string(REPLACE "RUNTIMES_default_" "" new_name ${variableName})
+      string(REPLACE ";" "|" new_value "${${variableName}}")
+      list(APPEND default_target_extra_args "-D${new_name}=${new_value}")
+    endif()
+  endforeach()
+
   if(LLVM_INCLUDE_TESTS)
     set_property(GLOBAL APPEND PROPERTY LLVM_ALL_LIT_TESTSUITES "@${LLVM_BINARY_DIR}/runtimes/runtimes-bins/lit.tests")
     list(APPEND test_targets runtimes-test-depends check-runtimes)
@@ -236,7 +258,7 @@
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
                                       ${COMMON_CMAKE_ARGS}
                                       ${RUNTIMES_CMAKE_ARGS}
-                                      ${ARG_CMAKE_ARGS}
+                                      ${default_target_extra_args}
                            PASSTHROUGH_PREFIXES LLVM_ENABLE_RUNTIMES
                                                 LLVM_USE_LINKER
                                                 ${ARG_PREFIXES}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145683.503723.patch
Type: text/x-patch
Size: 2516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230309/30260087/attachment.bin>


More information about the llvm-commits mailing list