Lessening the driver's reliance on default target triples

Hi cfe-dev,

The clang driver uses "default" and "effective" target triples in a rather ad
hoc way. Cleaning this up would have a few benefits:

  - Better error reporting. We have a few open bugs about error messages
    derived from default target triples, instead of more specific ones.

  - Less waste. Effective triples are needlessly recomputed in several
    different parts of the driver. This just needs to happen once per job.

  - Less confusion about which kind of triple to use in a given context. It
    should basically always be easy to use an effective triple.

We can't do away with default triples entirely. They appear to be needed to get
ToolChains. Once a ToolChain is available, we can get effective triples.

My plan is to remove uses of default triples in the driver until they are
*only* needed to compute effective triples. I don't know if this goal is
realistic, but I still expect incremental progress towards it to be beneficial.

What do people think of this plan?

best,
vedant

p.s:

To make this a bit more concrete, here are some initial patches:

  http://reviews.llvm.org/D22289 [Driver] Make Driver::DefaultTargetTriple private (NFCI)
  http://reviews.llvm.org/D22290 [Driver] Compute effective target triples once per job (NFCI)

Hi cfe-dev,

The clang driver uses "default" and "effective" target triples in a rather ad
hoc way. Cleaning this up would have a few benefits:

- Better error reporting. We have a few open bugs about error messages
   derived from default target triples, instead of more specific ones.

- Less waste. Effective triples are needlessly recomputed in several
   different parts of the driver. This just needs to happen once per job.

- Less confusion about which kind of triple to use in a given context. It
   should basically always be easy to use an effective triple.

We can't do away with default triples entirely. They appear to be needed to get
ToolChains. Once a ToolChain is available, we can get effective triples.

My plan is to remove uses of default triples in the driver until they are
*only* needed to compute effective triples. I don't know if this goal is
realistic, but I still expect incremental progress towards it to be beneficial.

What do people think of this plan?

I forgot to respond to the RFC. This makes sense to me -- making the effective triple canonical improves error messages and factors away a class of bugs.

Yep, sounds good.

Hi everybody,

Thanks for the feedback!

A heads-up to out-of-tree target owners:

I'm planning on committing some clang driver changes tomorrow. The commit
messages will include instructions for updating out-of-tree targets. I expect
the changes to be simple/mechanical (see D22290). Please let me know if you'd
like me to wait a bit longer.

vedant