[clang] llvm-lit test suites mostly failing locally with "(frontend): unknown target triple 'unknown'" [SOLVED]

This is a bit of a noob question but I couldn’t really find clear documentation on what I’m doing wrong. I’m used to llvm-lit with backend tests (I work on AVR mostly) and llvm-lit with Swift, it seems there are some extra nuances running tests locally for clang.

When I try to run a test suite on my Mac to test the clang I’ve just built, I’m seeing errors in many or most tests. This must just be an invocation problem my side I think…

carl@LT1152 llvm-project %  build/bin/llvm-lit --verbose clang/test/Parser
llvm-lit: /Users/carl/Documents/Code/llvm-project/llvm/utils/lit/lit/llvm/config.py:502: note: using clang: /Users/carl/Documents/Code/llvm-project/build/bin/clang
llvm-lit: /Users/carl/Documents/Code/llvm-project/llvm/utils/lit/lit/llvm/config.py:663: note: No default target triple was found, some tests may fail as a result.
-- Testing: 357 tests, 11 workers --
FAIL: Clang :: Parser/objcxx11-protocol-in-template.mm (1 of 357)
******************** TEST 'Clang :: Parser/objcxx11-protocol-in-template.mm' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /Users/carl/Documents/Code/llvm-project/build/bin/clang -cc1 -internal-isystem /Users/carl/Documents/Code/llvm-project/build/lib/clang/18/include -nostdsysteminc -fsyntax-only -verify /Users/carl/Documents/Code/llvm-project/clang/test/Parser/objcxx11-protocol-in-template.mm
+ /Users/carl/Documents/Code/llvm-project/build/bin/clang -cc1 -internal-isystem /Users/carl/Documents/Code/llvm-project/build/lib/clang/18/include -nostdsysteminc -fsyntax-only -verify /Users/carl/Documents/Code/llvm-project/clang/test/Parser/objcxx11-protocol-in-template.mm
error: 'expected-error' diagnostics seen but not expected: 
  (frontend): unknown target triple 'unknown'

I’m happy to test them on the local machine architecture (a Mac M3 silicon machine). How should I specify that?

Thanks for any help!

Carl

p.s. Footnote: Part of the problem might be a slightly odd configure step my end: arch -x86_64 cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS='clang;lld' -DLLVM_TARGETS_TO_BUILD="AVR;ARM" -DCMAKE_BUILD_TYPE=Release

While I’m waiting for feedback on this question, I’m also going to try rebuilding with a more normal cmake -B build -S llvm -G Ninja -DLLVM_ENABLE_PROJECTS='clang' -DCMAKE_BUILD_TYPE=Release for the purposes of getting these tests working.

OK, this is my naivety then!

I rebuilt the project with a normal build and now the tests run fine (as in I’m getting the same errors as the build kite server is showing, so I can now reproduce them and fix them).

This was just because my slightly odd copy/pasted make configure command from my own CI server build (for the AVR tooling) was not building clang to run on the local machine. So most tests were failing.

Bit of an obvious facepalm moment in hindsight!