Missing `lit` config file after swift compiler build

I've been able to run lit tests in the past successfully, however, this time after rebuilding the compiler (macOS) and invoking lit I'm stuck wtih an error.

lit.py: /Users/jan/Downloads/Dev/swift-project/llvm-project/llvm/utils/lit/lit/TestingConfig.py:152: fatal: unable to parse config file '/Users/jan/Downloads/Dev/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/lit.site.cfg', traceback: Traceback (most recent call last):
  ...
  FileNotFoundError: [Errno 2] No such file or directory: '/Users/jan/Downloads/Dev/swift-project/build/Ninja-DebugAssert/swift-macosx-arm64/test-macosx-arm64/lit.swift-features.cfg'

It mentions that I'm missing the lit.swift-features.cfg. I tried update-checkout from the build script, removed the build dir and built again, but that did not resolve it.

I simply followed the getting started page like last time:

utils/build-script --skip-build-benchmarks \
  --swift-darwin-supported-archs "$(uname -m)" \
  -d --swift-disable-dead-stripping \
  --bootstrapping=hosttools

I invoked the lit by executing a bash script that contains this line:

python3 "${PROJECT_DIR}/llvm-project/llvm/utils/lit/lit.py" -sv --param swift_site_config="${PROJECT_DIR}/build/${MODE}/swift-macosx-arm64/test-macosx-arm64/lit.site.cfg" "${PROJECT_DIR}/${TEST}"

I can't figure out why the lit.swift-features.cfg file isn't being generated this time. Any suggestions would be greatly appreciated!

This is a result of [test] Improve testing of Swift features by drodriguez · Pull Request #76740 · swiftlang/swift · GitHub. You should be able to invoke build-script with --test --skip-test-swift to fix this. cc @drodriguez

1 Like

Will rebuild with those flags now, thanks!

Update: Still encounter the error unfortunately. I'm going to rm the build dir, update checkout again and try again with the flags mentioned. Will update

You may need --reconfigure the first time, too.

Ah, that I had forgottent to do. I deleted the entire build for this time now so passing this shouldn't be needed

Update2: Error strangely persists :/ The output is exactly the same as shown here
Maybe I can try with just --test? Because that was what had worked for the commentor in the PR comment section

I actually faced the same issue recently, while the reconfigure should help I've not actually confirmed that yet.

If you'd like a silly workaround you can always just remove the lit.py: /Users/jan/Downloads/Dev/swift-project/llvm-project/llvm/utils/lit/lit/TestingConfig.py:152 line and it'll work just fine.

But we need to figure out so it perhaps just does configure the right way by default tbh.

i ran into this today as well – filed this issue regarding the problem. running once with --test resolved the issue for me (killed the build script after the tests attempted to run though).

Thanks for the suggestion, I tried removing the line you mentioned but I ended up running into another issue. Here's what I got:

File "/Users/jan/Downloads/Dev/swift-project/llvm-project/llvm/utils/lit/lit/worker.py", line 76, in _execute_test_handle_errors
    result = test.config.test_format.execute(test, lit_config)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'execute'

It seems like something might still be misconfigured since test_format is coming back as None.

Another workaround is to manually tell Ninja to build the files, in your build directory (e.g build/Ninja-ReleaseAssert/swift-macosx-arm64) run:

ninja test-macosx-arm64/lit.swift-features.cfg validation-test-macosx-arm64/lit.swift-features.cfg
1 Like

Thanks for filling the issue.
--test with --reconfigure still didn't seem to do the trick for me

This worked - thank you!

Executing lit directly with Python will not make the CMake dependencies system rebuild the necessary parts.

The recommended ways in the the guide are using run-test or CMake. Using lit.py directly is part of the guide, but one needs to have setup the build before using it, or most of the dependencies would not be built.

The line hamishknight provides using ninja is basically what run-test and CMake will do for you. There's a target check-swift-… which depends on swift-…-test-depends. The lit.site.cfg that needed to be generated and the new lit.swift-features.cfg are part of swift-…-test-depends. When one uses CMake to start the tests, they will be rebuild and regenerated. When one uses lit.py directly, you are skipping all the dependencies.

1 Like

FWIW, I usually use utils/run-test and I've noticed recently that it doesn't always cause lit.swift-features.cfg to be regenerated. When this has happened for me, running utils/build-script ... --test and then killing it once the tests have started is usually enough to fix it.

I haven't pinned down the conditions that have caused the file to be missing, though.

1 Like

Let's see if [test] Generate Lit Swift features file once during CMake generation by drodriguez · Pull Request #77658 · swiftlang/swift · GitHub avoids the errors (as long as the generation of the project happens once). What I fear is that it will hide whatever dependency is broken and it is causing the problems.

3 Likes

Tested and no errors on my end. Thank you for the fix :+1: