[cfe-dev] llvm-gcc/clang configuration defaults

Chris Lattner clattner at apple.com
Wed May 27 22:20:57 PDT 2009


On May 27, 2009, at 9:59 PM, Chris Lattner wrote:
>> The gcc community feels strongly it's important to have builds work
>> seamlessly, at least in common environments (somebody posted that  
>> view
>> here, Zack Weinberg I think, and it is widely held).  I'm not sure I
>> agree with this; the people we want working on llvm should be able to
>> figure it out, at least if we give reasonable directions in
>> README.LLVM, right?  But it's a view.
>
> Yes, I really think we should do this.  It would also be awesome to
> default Java (any any other languages that don't work with llvm-gcc)
> to off.

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



More information about the cfe-dev mailing list