This is an archive of the discontinued LLVM Phabricator instance.

[lit] Add `target=<triple>` as a feature keyword
ClosedPublic

Authored by probinson on Nov 4 2022, 8:48 AM.

Details

Summary

As proposed first in D107162 and later in discourse at
https://discourse.llvm.org/t/rfc-lits-requires-and-triples/66041

Modified a couple of lit's own tests to use this; left others as-is,
because for now triple substrings still work in UNSUPPORTED/XFAIL.

Diff Detail

Event Timeline

probinson created this revision.Nov 4 2022, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 8:48 AM
Herald added a subscriber: delcypher. · View Herald Transcript
probinson requested review of this revision.Nov 4 2022, 8:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2022, 8:48 AM

This is to detect the current/default target?

Should we instead support something more like the one in cross-project-tests, that adds a feature for every registered target? (that way a test can declare that it runs any time x86-registered-target is available, and it can specify the x86 target, so the test would run even on arm-default builds, for instance, so long as they also included x86?)

This is to detect the current/default target?

This is to allow checking the default target in a more principled way. Currently UNSUPPORTED/XFAIL (but not REQUIRES) can use arbitrary substrings of the default target triple as "feature keywords" and the end goal here is to replace all those with regexes against target=<triple> (thus allowing REQUIRES to check the target triple as well).

Should we instead support something more like the one in cross-project-tests, that adds a feature for every registered target? (that way a test can declare that it runs any time x86-registered-target is available, and it can specify the x86 target, so the test would run even on arm-default builds, for instance, so long as they also included x86?)

That's not what I see cross-project-tests doing; it's checking whether any of the registered targets match the _host_ because it wants to be able to build/test executable programs running on the host.

ldionne accepted this revision.Nov 8 2022, 1:07 PM
ldionne added a reviewer: yln.

This LGTM, but I think the commit should like to the Discourse thread that this was proposed in.

This revision is now accepted and ready to land.Nov 8 2022, 1:07 PM

This is to detect the current/default target?

This is to allow checking the default target in a more principled way. Currently UNSUPPORTED/XFAIL (but not REQUIRES) can use arbitrary substrings of the default target triple as "feature keywords" and the end goal here is to replace all those with regexes against target=<triple> (thus allowing REQUIRES to check the target triple as well).

Should we instead support something more like the one in cross-project-tests, that adds a feature for every registered target? (that way a test can declare that it runs any time x86-registered-target is available, and it can specify the x86 target, so the test would run even on arm-default builds, for instance, so long as they also included x86?)

That's not what I see cross-project-tests doing; it's checking whether any of the registered targets match the _host_ because it wants to be able to build/test executable programs running on the host.

Not sure I follow - this code ( https://github.com/llvm/llvm-project/blob/e044796132abd9e10e21093822dc234003628fbd/cross-project-tests/lit.cfg.py#L256-L258 ) appears to be adding a <arch>-registered-target for every architecture that's enabled, not related to whether they match the host triple. Oh, and that's already in clang and used a lot there, so maybe porting that feature over to LLVM?

But registered-target is for all the registered targets (& only the architecture, not the OS, etc, in the triple) - what's the particular need for the default target (unless it's native - which is useful for executing the code).

I guess it means a test can be written generically rather than REQUIRES target + hardcoded target on the test execution, etc?

If there's a discourse thread as @ldionne mentioned, yeah, be good to have a link for context, etc.

Should we instead support something more like the one in cross-project-tests, that adds a feature for every registered target? (that way a test can declare that it runs any time x86-registered-target is available, and it can specify the x86 target, so the test would run even on arm-default builds, for instance, so long as they also included x86?)

That's not what I see cross-project-tests doing; it's checking whether any of the registered targets match the _host_ because it wants to be able to build/test executable programs running on the host.

Not sure I follow - this code ( https://github.com/llvm/llvm-project/blob/e044796132abd9e10e21093822dc234003628fbd/cross-project-tests/lit.cfg.py#L256-L258 ) appears to be adding a <arch>-registered-target for every architecture that's enabled, not related to whether they match the host triple. Oh, and that's already in clang and used a lot there, so maybe porting that feature over to LLVM?

But registered-target is for all the registered targets (& only the architecture, not the OS, etc, in the triple) - what's the particular need for the default target (unless it's native - which is useful for executing the code).

Assuming I captured the link correctly, what I was looking at is this:
https://github.com/llvm/llvm-project/blob/e044796132abd9e10e21093822dc234003628fbd/cross-project-tests/lit.cfg.py#L164

REQUIRES: native is probably a better choice for those cross-project-tests, it may be that the people who set up that directory were not aware of that feature keyword and rolled their own. I don't know. It wasn't my intent to fix things like that.

probinson edited the summary of this revision. (Show Details)Nov 9 2022, 5:19 PM

Patch description updated with the previous patch and discourse thread where this was discussed.

Fair enough - thanks for the link to context.

Any chance this could be put in one place/shared across all LLVM projects, rather than duplicated in subprojects (the thread mentions this is already in libcxx, for instance - be nice to put it in one place so everyone gets it? (does this patch make the libcxx feature redundant/could it be removed?))

MaskRay accepted this revision.Nov 9 2022, 5:45 PM
MaskRay added a subscriber: MaskRay.

Looks great!

Any chance this could be put in one place/shared across all LLVM projects, rather than duplicated in subprojects (the thread mentions this is already in libcxx, for instance - be nice to put it in one place so everyone gets it? (does this patch make the libcxx feature redundant/could it be removed?))

This patch does cause target=<triple> to be shared across all LLVM projects. The code in libcxx to define the same thing is harmlessly redundant and could be removed; I do plan to get to that eventually, if @ldionne doesn't beat me to it.

Any chance this could be put in one place/shared across all LLVM projects, rather than duplicated in subprojects (the thread mentions this is already in libcxx, for instance - be nice to put it in one place so everyone gets it? (does this patch make the libcxx feature redundant/could it be removed?))

This patch does cause target=<triple> to be shared across all LLVM projects. The code in libcxx to define the same thing is harmlessly redundant and could be removed; I do plan to get to that eventually, if @ldionne doesn't beat me to it.

Ah, nice!

Is this blocked on anything?

Is this blocked on anything?

Just me being swamped by other things. I hope to get this in today.

This revision was landed with ongoing or failed builds.Nov 16 2022, 5:51 AM
This revision was automatically updated to reflect the committed changes.