[PATCH] D62353: [cmake] Add new LLVM_CACHE_VARIABLES variable to contains all variables passed to cmake on the commandline or in cache files.

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 16:19:53 PDT 2019


hintonda created this revision.
hintonda added reviewers: beanz, labath, smeenai, phosek.
Herald added subscribers: kadircet, ilya-biryukov, mgorny.
Herald added a project: LLVM.

This patch gathers all variables passed to cmake, adds them
to a list in the cache, and prints them out.  This is helpful for
debugging, especially in the buildbots, but could also be used to
automatically decide what to pass down to cmake when building NATIVE
tools.

Here's an example of what it prints:

  -- *** Gathering initial cache variables -- from command line and/or cache files into LLVM_CACHE_VARIABLES ***
  -- from commandline or cache files: CLANGD_BUILD_XPC = OFF
  -- from commandline or cache files: CMAKE_BUILD_TYPE = Debug
  -- from commandline or cache files: CMAKE_CXX_FLAGS = -I/opt/local/include
  -- from commandline or cache files: CMAKE_C_FLAGS = -I/opt/local/include
  -- from commandline or cache files: CMAKE_GENERATOR = Ninja
  -- from commandline or cache files: GOLD = GOLD-NOTFOUND
  -- from commandline or cache files: LLVM_APPEND_VC_REV = OFF
  -- from commandline or cache files: LLVM_ENABLE_PROJECTS = Scratch;clang;libcxx;libcxxabi
  -- from commandline or cache files: LLVM_EXTERNAL_PROJECTS = Scratch
  -- from commandline or cache files: LLVM_INCLUDE_BENCHMARKS = OFF
  -- from commandline or cache files: LLVM_LIT_ARGS = '-vv'
  -- from commandline or cache files: LLVM_OPTIMIZED_TABLEGEN = ON
  -- from commandline or cache files: LLVM_TARGETS_TO_BUILD = X86

And the corresponding LLVM_CACHE_VARIABLES variable added to the cache:

  LLVM_CACHE_VARIABLES:STRING=CLANGD_BUILD_XPC;CMAKE_BUILD_TYPE;CMAKE_CXX_FLAGS;CMAKE_C_FLAGS;CMAKE_GENERATOR;GOLD;LLVM_APPEND_VC_REV;LLVM_ENABLE_PROJECTS;LLVM_EXTERNAL_PROJECTS;LLVM_INCLUDE_BENCHMARKS;LLVM_LIT_ARGS;LLVM_OPTIMIZED_TABLEGEN;LLVM_TARGETS_TO_BUILD


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62353

Files:
  llvm/CMakeLists.txt


Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -1,5 +1,30 @@
 # See docs/CMake.html for instructions about how to build LLVM with CMake.
 
+# Generate a list of variables passed to cmake and save the list in
+# the cache.  This list could be used to figure out what should when
+# building host tools for cross-compiles.
+# TODO: We could compare the list to the previous run, issue
+# diagnostics and save the new list, but not sure that's worthwhile.
+if(NOT LLVM_CACHE_VARIABLES)
+  # Needed for IN_LIST below
+  if(POLICY CMP0057)
+    cmake_policy(SET CMP0057 NEW)
+  endif()
+  set(IGNORE_LIST CMAKE_COMMAND CMAKE_CPACK_COMMAND CMAKE_CTEST_COMMAND CMAKE_GENERATOR_PLATFORM CMAKE_GENERATOR_TOOLSET CMAKE_HOME_DIRECTORY CMAKE_ROOT)
+  message(STATUS "*** Gathering initial cache variables -- from command line and/or cache files int LLVM_CACHE_VARIABLES ***")
+  get_cmake_property(vars CACHE_VARIABLES)
+  foreach(var ${vars})
+    if(var IN_LIST IGNORE_LIST)
+      continue()
+    endif()
+    list(APPEND LLVM_CACHE_VARIABLES ${var})
+  endforeach()
+  set(LLVM_CACHE_VARIABLES ${LLVM_CACHE_VARIABLES} CACHE STRING "List of variables passed to cmake on the commandline or in cache files." FORCE)
+  foreach(var ${LLVM_CACHE_VARIABLES})
+    message(STATUS "from commandline or cache files: ${var} = ${${var}}")
+  endforeach()
+endif()
+
 cmake_minimum_required(VERSION 3.4.3)
 
 if(POLICY CMP0068)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62353.201086.patch
Type: text/x-patch
Size: 1506 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190523/92e7a848/attachment-0001.bin>


More information about the llvm-commits mailing list