[PATCH] D37756: [lit] Force site configs to be run before source-tree configs
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 12 12:12:02 PDT 2017
zturner created this revision.
Herald added a subscriber: mgorny.
Herald added a reviewer: modocache.
Herald added a reviewer: bollu.
This patch simplifies LLVM's lit infrastructure by enforcing an ordering that a site config is always run before a source-tree config. There are multiple ways of running lit. The most common are:
Run `lit.py` from the source tree against a directory or file also in the source tree, specifying various parameters like `llvm_site_config=<foo>`
- This is what the `ninja check` targets currently do.
Run `llvm-lit.py` from the build tree against a directory or file in the source tree, specifying no other parameters.
- This is what developers usually do.
Run `llvm-lit.py` from the source tree against a directory or file in the build tree.
- This is necessary to run asan tests, where you cannot currently run against a directory in the source tree.
Run `lit.py` from the source tree against a directory in the build tree.
- Not aware of anyone who does this, but in theory it should work.
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 executed. It is *always* necessary to execute a site config first, because it initializes variables that are handed down through CMake that the main configuration depends on.
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:
1. We are guaranteed that a site config will be executed first
2. Inside of a main config, we no longer have to assume that attributes might not be present and use `getattr` everywhere.
3. We no longer have to pass parameters such as `--param llvm_site_config=<path>` on the command line.
4. It is future-proof, meaning you don't have to edit `llvm-lit.in` to add support for new projects.
5. 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, the first method is now deprecated and no longer works.
I have tested the following:
- Running check targets `ninja check-llvm`, `ninja check-llvm-unit`, `ninja check-lld`, `ninja check-clang`, `ninja check-clang-unit`
- Running `llvm-lit.py` against individual directories in the `llvm/test`, `llvm/unittests`, `lld/test`, `clang/test`, `clang/unittests` folder.
- Running `lit.py` against corresponding directories in the build folder.
I think these three scenarios are enough to show that everything works, but if someone wants to help me test `compiler-rt` that would be great.
https://reviews.llvm.org/D37756
Files:
clang-tools-extra/test/Unit/lit.cfg
clang-tools-extra/test/lit.cfg
clang/test/Unit/lit.cfg
clang/test/lit.cfg
compiler-rt/test/lit.common.cfg
compiler-rt/test/profile/lit.cfg
compiler-rt/unittests/lit.common.unit.cfg
lld/test/Unit/lit.cfg
lld/test/Unit/lit.site.cfg.in
lld/test/lit.cfg
lldb/lit/Unit/lit.cfg
lldb/lit/lit.cfg
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/test/Unit/lit.cfg
llvm/test/lit.cfg
llvm/utils/lit/lit/discovery.py
llvm/utils/lit/tests/lit.cfg
llvm/utils/llvm-lit/CMakeLists.txt
llvm/utils/llvm-lit/llvm-lit.in
polly/test/Unit/lit.cfg
polly/test/lit.cfg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37756.114874.patch
Type: text/x-patch
Size: 65049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170912/1c4753be/attachment.bin>
More information about the llvm-commits
mailing list