[PATCH] D72947: [CMake] llvm/runtimes: Do not override LLVM_* variables with just-built LLVM configurations

James Nagurne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 12:38:23 PST 2020


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

  In the projects generated by llvm/runtimes/CMakeLists.txt, using that same
  file, there is a find_package for LLVM. This imports the just-built
  toolchain's configurations. Among these configurations is LLVM_ENABLE_PIC.
  
  A runtimes configuration might want to build the toolchain with PIC and
  build the runtimes without PIC, but the aforementioned behavior will always
  prefer the LLVM's configuration of using PIC. I suggest that this is
  undesirable behavior, and the overrides sent into the runtime configuration
  via 'RUNTIMES_<target>_LLVM_ENABLE_PIC' should take precedence.
  
  To that end, I've added a loop after the find_package which reinforces
  the definition of variables found in the cache. Should LLVM_ENABLE_PIC
  be in that cache, its value will take precedence over the just-build
  toolchain.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72947

Files:
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -61,6 +61,14 @@
 
   find_package(LLVM PATHS "${LLVM_BINARY_DIR}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)
 
+  # find_package may have overridden some cache variables which ought not be
+  # overridden for a build using the just-built toolchain. Revert them.
+  get_cmake_property(_variableNames CACHE_VARIABLES)
+  foreach (_variableName ${_variableNames})
+      get_property(original_value CACHE ${_variableName} PROPERTY VALUE)
+      set(${_variableName} ${original_value})
+  endforeach()
+
   # Add the root project's CMake modules, and the LLVM build's modules to the
   # CMake module path.
   list(INSERT CMAKE_MODULE_PATH 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72947.238857.patch
Type: text/x-patch
Size: 809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200117/647bf099/attachment.bin>


More information about the llvm-commits mailing list