This is an archive of the discontinued LLVM Phabricator instance.

Distinguish "native" from "native-arch" in lit testing
AbandonedPublic

Authored by probinson on Aug 31 2015, 4:13 PM.

Details

Summary

"REQUIRES: native" means the compiled code needs to be runnable on the
host. Things like JIT and lli may need this.

"REQUIRES: native-arch" (new in this commit) means that the host's
arch needs to be one of the configured targets. Some tools, e.g. llc,
will default to the host triple if none is specified, and will fail if
the host's arch is not included (e.g. building on X86 and only the ARM
target is included).

Adds lit.cfg code to set "native-arch" and modifies all the places
where r243960 added "native" to use "native-arch" instead.

Diff Detail

Event Timeline

probinson updated this revision to Diff 33642.Aug 31 2015, 4:13 PM
probinson retitled this revision from to Distinguish "native" from "native-arch" in lit testing.
probinson updated this object.
probinson added a subscriber: llvm-commits.
chapuni edited edge metadata.Aug 31 2015, 4:31 PM

This change itself seems fine, .. but I don't understand why it is needed.
Should we fix the root cause anyways?

I don't oppose to commit this if there'd be any cases that really require "native" codegen.

AFAIK, It's just JIT that runs as LLVM_HOST_TRIPLE by default target.
(I found llvm-ar depends on host triple by trivial reason)

I suppose most of tools, like llc, are runs with LLVM_DEFAULT_TARGET_TRIPLE, not HOST_TRIPLE.
I guess configure script might miss checking whether targets_to_build covers target_triple.

The native use-case is still not clearly motivated to me: it seems that it comes from the JIT tools (lli, other?) defaulting to the default LLVM triple, while I would expect them to default to the host triple.

If changing the tools is not desirable (why?), then the tests could be updated by always forcing the JIT to use the host on the command line (exporting the host triple as an env var and passing it on the RUN: line).

llvm/test/lit.cfg
343

"objects compiled for the *default* target triple will run the host".

I was mis-remembering some research from maybe six months ago... in fact llc does *not* default to the host triple, it will pay attention to the default triple. The sequence is:

  • take the triple from the IR, if specified
  • triple from the command line will override this, if specified
  • if still no triple is set, use default target triple specified at build time

So, as an experiment I should have done in the first place, I took an LLVM hosted on X86 with only the ARM backend included, and a default LLVM triple set to an ARM value. I removed llvm/test/DebugInfo/lit.local.cfg (essentially undoing Mehdi's change) and then ran the DebugInfo tests under llvm-lit. They basically worked (2 unexpected failures out of 100 or so). One was a segfault, one is something that has commentary about it being a bit flakey.

@Mehdi, this suggests that your change should not have been necessary in the first place. What configuration were you using that caused so many failures?

LLVM hosted on X86 with only the ARM backend included, no default LLVM triple specified.

In D12506#237342, @joker.eph wrote:

LLVM hosted on X86 with only the ARM backend included, no default LLVM triple specified.

That seems like a build-configuration mistake. I believe if you don't explicitly configure a triple, the default target triple is set to the host triple. Using a default triple for a target that you have not included doesn't make any sense?

It's a bug in configuration. But AFAIK it has not been filed.
Also configure doesn't check if --enable-targets didn't cover --target.

I suppose as if this issue were our common sense.
Should we file bugs?

Using the DEFAULT_TRIPLE to run the validation on test that were not designed for this triple does not make any sense either. I'm validating GPU backends, and it won't be able to handle all the test cases that were not written specifically for it. There is absolutely no guarantee in general that a backend will properly handle the IR generated and processed for another target.
For instance, I just tried to configure the default target triple to "amdgcn--amdhsa" and configure in the X86 and AMDGPU backends. Running ninja check yields 202 failures.

I see. So then, we should clarify

  • DEFAULT_TARGET_TRIPLE is just default, and it wouldn't work if one didn't configure TARGETS_TO_BUILD didn't cover DEFAULT_TARGET_TRIPLE.

And we may work for;

  • Make sure tools (including clang) should fail without explicit triple (or explicit arch) in this configuration. Note, environment might be inferred from DEFAULT_TARGET_TRIPLE with -march.
  • Introduce the new feature like "DEFAULT_TARGET_UNAVAILABLE" in Lit tests for it.

This may be fed to llvmdev for the discussion.

In D12506#237410, @joker.eph wrote:

For instance, I just tried to configure the default target triple to "amdgcn--amdhsa" and configure in the X86 and AMDGPU backends. Running ninja check yields 202 failures.

Yes, but I just tried an ARM-backend-only configuration (r243957, prior to your changes) running on X86, default triple "armv7a--linux" and running 'ninja check' yielded NO failures. So I think your issues have more to do with GPU backends not being general-purpose, rather than the host-arch not being one of the available targets. You have applied too big a hammer to the problem, and turned off testing configurations that are actually valuable.

I think Takumi is correct, this needs to be discussed on the dev list. I am unlikely to have time to write up a proper description today so if you want to, go ahead; if you don't I will probably get to it tomorrow.

probinson abandoned this revision.Sep 17 2015, 4:56 PM

Superseded by D12660/r247775.