[llvm-dev] Cannot run LLVM unit tests doe to python error in lit
Sergej Jaskiewicz via llvm-dev
llvm-dev at lists.llvm.org
Fri Aug 23 02:51:20 PDT 2019
Thank you for pointing a direction, Michael.
This allowed me to investigate the issue, which was not in lit, but rather in CMake configuration.
The issue was that when llvm-lit.py was executed, 'config_map', which maps lit config files from source directory to build directory, was empty, because the template for llvm-lit.py, llvm-lit.in, contains @LLVM_LIT_CONFIG_MAP@, which was being expanded to an empty string.
Why was it expanded to an empty string?
Well, as I’ve said, I’m building a cross-toolchain, which means that first I build llvm & clang, and then using the just-built compiler compiler-rt and friends are built. All of this in a single Ninja invocation. This is achieved by setting the -DLLVM_ENABLE_RUNTIMES="compiler-rt;libunwind;libcxxabi;libcxx" flag.
It turns out that everything is OK at configure time for LLVM & clang, @LLVM_LIT_CONFIG_MAP@ is expanded correctly. But then, during the ninja invocation, after the compiler is built, a new CMake command is run _at build time_ to configure and build compiler-rt (namely builtins & runtimes) using the just-built compiler. This new CMake invocation calls ‘configure_file’ again, this time replacing @LLVM_LIT_CONFIG_MAP@ with an empty string, erasing the previous expansion.
I’ll see if I can fix this, but currently I guess a workaround would be to first build LLVM & clang with -DLLVM_ENABLE_RUNTIMES="", run the relevant tests, and only then build the runtimes.
> On 21 Aug 2019, at 21:41, Michael Kruse <llvmdev at meinersbur.de> wrote:
> llvm_obj_root is supposed to be assigned in lit.site.cfg.py.in
> config.llvm_obj_root = "@LLVM_BINARY_DIR@"
> (which will `configure_file`ed by cmake). I can run ninja
> check-llvm-unit on my Windows machine without problems. Maybe look for
> lit.site.cfg.py in your build dir
> Am Mi., 21. Aug. 2019 um 10:52 Uhr schrieb Sergej Jaskiewicz via
> llvm-dev <llvm-dev at lists.llvm.org>:
>> Hello, LLVM community.
>> I've built a cross-toolchain on Windows and I'm now trying to run unit tests for the LLVM libraries.
>> I used Ninja as a build system and MSVC as host compiler without an issue, but when I try to run 'ninja check-llvm-unit', I get the following error:
>> llvm-lit.py: C:/Users/sergej/Developer/llvm-project/llvm\utils\lit\lit\TestingConfig.py:102: fatal: unable to parse config file 'C:\\Users\\sergej\\Developer\\llvm-project\\llvm\\test\\Unit\\lit.cfg.py', traceback: Traceback (most recent call last):
>> File "C:/Users/sergej/Developer/llvm-project/llvm\utils\lit\lit\TestingConfig.py", line 89, in load_from_path
>> exec(compile(data, path, 'exec'), cfg_globals, None)
>> File "C:\Users\sergej\Developer\llvm-project\llvm\test\Unit\lit.cfg.py", line 24, in <module>
>> config.test_exec_root = os.path.join(config.llvm_obj_root, 'unittests')
>> AttributeError: 'TestingConfig' object has no attribute 'llvm_obj_root'
>> FAILED: test/CMakeFiles/check-llvm-unit
>> From what I can see, the TestingConfig class (which can be found in llvm/utils/lit/lit/TestingConfig.py) doesn't have this 'llvm_obj_root' indeed. Also I can't spot any Python magic here like __getattr__. How is this supposed to work?
>> Reproducible with both Python 2 and 3.
>> Maybe anyone has an idea? I’d really appreciate any help
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
More information about the llvm-dev