New way to check target triple in lit tests

It’s common to want to constrain lit tests for a particular target (triple). As described in [RFC] lit's REQUIRES and triples, recently lit learned a new way to do this: It will automatically create a feature with the name target=<triple>, for example target=x86_64-unknown-linux-gnu. Unlike the previous way to check for a target, this works for REQUIRES, UNSUPPORTED, and XFAIL. The libcxx project and its companions have been using this scheme for a while, and it seems to work very well.

Combined with regular expressions, this allows for a lot of flexibility in checking for targets.

REQUIRES: target={{(arm|aarch64).*-linux.*}}
UNSUPPORTED: target={{.*-windows-msvc}}
XFAIL: target=thumb{{.*}}

Previously, lit supported arbitrary substrings of the target triple just as a word, and it didn’t work for REQUIRES (sometimes people would use UNSUPPORTED: !(expression) to work around this).

UNSUPPORTED: !((arm || aarch64) && -linux)
UNSUPPORTED: windows-msvc
XFAIL: thumb

The new syntax is a little more verbose, but seems overall clearer about its intent.

I’ve made a couple of passes over the existing in-tree lit tests, and I’m fairly confident I’ve converted everything. The old syntax will be going away early in the new year, so please start using it!

Downstream LLVM projects will need to adapt their local lit tests in the same way.

Note: If your lit.cfg (or equivalent) explicitly defines features based on the triple, those are still in place. I’d recommend replacing those with direct target= usage instead, but the changes to lit itself will not require that.

Please post discussion or objections to the other Discourse topic cited above.


I’ve committed the change to lit that disables checking for triple substrings here.
This change will go out in LLVM 16.0.0, and I’ve added a Release Note describing it.