Q on Flang's lit testing

I’m working my way through the various sub-projects as part of implementing the lit change described in [RFC] lit's REQUIRES and triples - #8 by pogo59

Flang has only 3 tests that do the triple-substring thing, but my initial experiment with flang tests suggests that something isn’t right.

On Windows, I built llvm/clang/flang with target triple arm64-apple-darwin because I saw two of the three tests had UNSUPPORTED: darwin in them. I was kind of surprised to see these tests pass.

It looks like flang/test/lit.site.cfg.py.in does not set config.target_triple and therefore the default target triple doesn’t get passed down into the lit configuration. That’s easy enough to fix, but it makes me wonder how flang testing works in the first place, that these UNSUPPORTED conditions could simply not be working. And yet in at least one case, a condition was added after the fact, suggesting there was a problem and that fixed it. I don’t understand how.

I hope someone can explain, so I can get my project finished… thanks!

Would the comments and changes in the following patch answer some of your questions?

https://reviews.llvm.org/D138530

Thanks. It doesn’t explain what LLVM_TARGET_TRIPLE_ENV is supposed to be?

Also, if you don’t set FLANG_TEST_TARGET_TRIPLE, you end up with an empty string for the target triple, which means things like UNSUPPORTED: darwin will never match.

Edit: Other projects use LLVM_TARGET_TRIPLE to set config.target_triple in their lit.site.cfg.py.in file, FYI.

It looks like flang does set config.target_triple but only in the test/Unit/lit.cfg.py.in file.
Perhaps we missed adding it in the test/lit.cfg.py.in file?

config.target_triple = “@LLVM_TARGET_TRIPLE@”


Regarding D138530 I updated the commit message and thought that it would also update the summary, but it didn’t.

The use is like this: -DLLVM_TARGET_TRIPLE_ENV="<some string>" -DFLANG_TEST_TARGET_TRIPLE="aarch64-linux-gnu" to use aarch64 as the default flang test triple.

LLVM_TARGET_TRIPLE_ENV can be any string. It just names an environment variable that can change the default LLVM triple when set.

Example:

> clang -v
clang version 15.0.0
Target: arm-unknown-linux-gnueabi

# compile with -DLLVM_TARGET_TRIPLE_ENV=“xyz”

> export xyz=“aarch64-windows-pc”
> clang -v
clang version 15.0.0
Target: aarch64-pc-windows-msvc

2 Likes

Oooh spiffy. Thanks for the explanation!

I can add the line to the lit config file as part of my other work. I’ll have a couple of patches for you soon.