llvm-gcc/clang configuration defaults

Incidentally, I think we should follow a very different route for clang than llvm-gcc, mainly because things are easier to implement in clang than gcc. The second major difference between the two is that one clang binary fully supports cross compilation to multiple targets with the "clang -triple x-y-z" option (the major caveat being that you still have to install assembler and linkers for these targets).

Given this, we have multiple questions:

1) what target+cpu should you get code for by default (no target triple specified)?
2) what cpu you should get code for when you specify a target?
3) how should the capabilities of clang be configured at clang build time?

I think we should follow a very simple policy:

1. If -mcpu or -mtune are specified, use them (duh).
2. A clang tool chain can specify a default cpu/tune pair for a triple. For example, i386-darwin can default to sse3 if it wants to. If we have a preferred default for a *triple*, use it. This should kick in for darwin but not linux.
3. If the selected target matches the host, default to the native CPU type. If I build on a nehalem linux machine with no flags, clang should default to -mcpu=nehalem.
4. Only if none of the above apply should we default to the arch-specified (not triple specified) lowest cpu. For example, we could choose for the i386 architecture to default to pentium4 (to ensure that we get at least SSE2). This would only apply if you're building with -triple=i386-... on a ppc machine with no -mcpu specified, for example.

I think we really want to optimize for the common case and make the compiler "do the right thing" without having to hand held. I'd really like for clang to be completely driven by the --enable-targets setting in LLVM: a clang cross compiler should support all the llvm targets that are linked into it. The one big issue is finding assembler/linkers and emitting nice error messages, but that shouldn't prevent -S from working.

Incidentally, I think llvm-gcc should also work this way, but it is probably more effort than it is worth.

-Chris

I think we should follow a very simple policy:

Sounds good. As far as the "none-of-the-above" it might be best to just default to native (i.e. options 3 and 4) and leave triples out of configuration since clang/llvm already support every target (or can).

Incidentally, I think llvm-gcc should also work this way, but it is
probably more effort than it is worth.

Most assuredly. :slight_smile:

-eric