[cfe-dev] __x86_64__ not defined

Chris Lattner clattner at apple.com
Mon Oct 29 10:31:54 PDT 2007


On Oct 29, 2007, at 1:09 AM, Giangiacomo Mariotti wrote:

> On my Debian X86_64 some tests fail because clang searches for  
> stubs-32.h when it should be searching for stubs-64.h, and that's  
> because __x86_64__ is not defined, so "# define __WORDSIZE    32"  
> is chosen instead of "# define __WORDSIZE    64".

In answer to your specific problem, please try passing "-arch x86_64"  
to clang.

There is a bigger answer here though.  Right now, clang is overly mac- 
specific and the target handling code is basically hacked in.  What  
we really want is for clang to transparently support cross  
compilation and architecture switching.  Specifically, we want to be  
able to do things like:

$ clang -arch ppc -os linux ...
$ clang -target-triple powerpc-apple-darwin8 ...
$ clang -arch x86_64 ...

The idea is that clang can support cross compiling very easily, by  
linking in any or all of the LLVM backends that are interesting for a  
person, or dynamically load them from the disk if needed.  If you  
build a "maximal" clang with support for all backends, you should be  
able to select any supported target with the -target-triple option.   
This would allow you to pick your os and architecture in one step.

If the target triple is not specific, clang should default to  
matching the architecture and os that it is running on.  To tweak  
that, the -arch option can be used to change just the architecture,  
independently of the os.  On a darwin ppc box, for example "clang - 
arch x86_64" would produce code for darwin/x86-64.

Right now, the major framework for supporting multiple targets is in  
place, but not multiple OS's.  Also, there is not really any good  
code for detecting and specifying OS-specific #defines etc.

Any help with this would be appreciated, the relevant code is very  
simple and lives in Driver/Targets.cpp.

-Chris



More information about the cfe-dev mailing list