aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-09-14 16:47:58 +0000
committerZachary Turner <zturner@google.com>2017-09-14 16:47:58 +0000
commit837d04db84ad724b89004f46e137f6d49bc3ea65 (patch)
tree517de727dedca7dac907e64904b81795d77abc52 /cmake/modules
parente6834d6e1a2bbba486f1cd8e54197b7b61873bf1 (diff)
downloadllvm-837d04db84ad724b89004f46e137f6d49bc3ea65.tar.gz
[lit] Force site configs to be run before source-tree configs
This patch simplifies LLVM's lit infrastructure by enforcing an ordering that a site config is always run before a source-tree config. A significant amount of the complexity from lit config files arises from the fact that inside of a source-tree config file, we don't yet know if the site config has been run. However it is *always* required to run a site config first, because it passes various variables down through CMake that the main config depends on. As a result, every config file has to do a bunch of magic to try to reverse-engineer the location of the site config file if they detect (heuristically) that the site config file has not yet been run. This patch solves the problem by emitting a mapping from source tree config file to binary tree site config file in llvm-lit.py. Then, during discovery when we find a config file, we check to see if we have a target mapping for it, and if so we use that instead. This mechanism is generic enough that it does not affect external users of lit. They will just not have a config mapping defined, and everything will work as normal. On the other hand, for us it allows us to make many simplifications: * We are guaranteed that a site config will be executed first * Inside of a main config, we no longer have to assume that attributes might not be present and use getattr everywhere. * We no longer have to pass parameters such as --param llvm_site_config=<path> on the command line. * It is future-proof, meaning you don't have to edit llvm-lit.in to add support for new projects. * All of the duplicated logic of trying various fallback mechanisms of finding a site config from the main config are now gone. One potentially noteworthy thing that was required to implement this change is that whereas the ninja check targets previously used the first method to spawn lit, they now use the second. In particular, you can no longer run lit.py against the source tree while specifying the various `foo_site_config=<path>` parameters. Instead, you need to run llvm-lit.py. Differential Revision: https://reviews.llvm.org/D37756 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313270 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/modules')
-rw-r--r--cmake/modules/AddLLVM.cmake21
1 files changed, 16 insertions, 5 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 66abb2486d9..b30d002aa20 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -1174,6 +1174,13 @@ function(configure_lit_site_cfg input output)
endif()
configure_file(${input} ${output} @ONLY)
+ get_filename_component(INPUT_DIR ${input} DIRECTORY)
+ if (EXISTS "${INPUT_DIR}/lit.cfg")
+ set(PYTHON_STATEMENT "map_config('${INPUT_DIR}/lit.cfg', '${output}')")
+ get_property(LLVM_LIT_CONFIG_MAP GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP)
+ set(LLVM_LIT_CONFIG_MAP "${LLVM_LIT_CONFIG_MAP}\n${PYTHON_STATEMENT}")
+ set_property(GLOBAL PROPERTY LLVM_LIT_CONFIG_MAP ${LLVM_LIT_CONFIG_MAP})
+ endif()
endfunction()
# A raw function to create a lit target. This is used to implement the testuite
@@ -1185,12 +1192,16 @@ function(add_lit_target target comment)
if (NOT CMAKE_CFG_INTDIR STREQUAL ".")
list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
endif ()
- if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
- set (LIT_COMMAND "${PYTHON_EXECUTABLE};${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py"
- CACHE STRING "Command used to spawn llvm-lit")
- else()
- find_program(LIT_COMMAND NAMES llvm-lit lit.py lit)
+
+ if (WIN32 AND NOT CYGWIN)
+ # llvm-lit needs suffix.py for multiprocess to find a main module.
+ set(suffix .py)
endif ()
+ set(llvm_lit_path ${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lit${suffix})
+
+ set (LIT_COMMAND "${PYTHON_EXECUTABLE};${llvm_lit_path}"
+ CACHE STRING "Command used to spawn llvm-lit" FORCE)
+
list(APPEND LIT_COMMAND ${LIT_ARGS})
foreach(param ${ARG_PARAMS})
list(APPEND LIT_COMMAND --param ${param})