[PATCH] D71570: [CMake] Prefer multi-target variables over generic target variables in runtimes build

James Nagurne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 14:16:45 PST 2019


JamesNagurne created this revision.
JamesNagurne added a reviewer: phosek.
Herald added subscribers: llvm-commits, mgorny.
Herald added a project: LLVM.

Runtimes variables in a multi-target environment are defined like:

RUNTIMES_target_VARIABLE_NAME
RUNTIMES_target+multi_VARIABLE_NAME

In my case, I have a downstream runtimes cache that does the following:

set(RUNTIMES_${target}+except_LIBCXXABI_ENABLE_EXCEPTIONS ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")

I found that I was always getting the 'target' variable value (OFF) in my 'target+except' build, which was unexpected.
This behavior was caused by the loop in llvm/runtimes/CMakeLists.txt that runs through all variable names, adding '-DVARIABLE_NAME=' options to the subsequent external project's cmake command.

The issue is that the loop does a single pass, such that if the 'target' value appears in the cache after the 'target+except' value, the 'target' value will take precedence. I suggest in my change here that the more specific 'target+except' value should take precedence always, without relying on CMake cache ordering.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71570

Files:
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -448,14 +448,16 @@
 
     get_cmake_property(variableNames VARIABLES)
     foreach(variableName ${variableNames})
-      string(FIND "${variableName}" "RUNTIMES_${name}_" out)
+      string(FIND "${variableName}" "RUNTIMES_${target}_" out)
       if("${out}" EQUAL 0)
-        string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
+        string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
         list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
       endif()
-      string(FIND "${variableName}" "RUNTIMES_${target}_" out)
+    endforeach()
+    foreach(variableName ${variableNames})
+      string(FIND "${variableName}" "RUNTIMES_${name}_" out)
       if("${out}" EQUAL 0)
-        string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
+        string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
         list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
       endif()
     endforeach()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71570.234147.patch
Type: text/x-patch
Size: 1153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191216/4709d7c1/attachment.bin>


More information about the llvm-commits mailing list