Does clang work on X86-64 machines?

I get the below mentioned errors on compiling the attached file with clang.
I have installed clang on a x86-64 machine (intel xeon core 2 duo
2.66ghz) running Suse linux for X86-64 with kernel 2.6.18.8-0.9

The same program is handled by clang without error messages on the
same machine running 32bit linux with the same kernel.

memcopy.c (859 Bytes)

Santosh Nagarakatte wrote:

I get the below mentioned errors on compiling the attached file with clang.
I have installed clang on a x86-64 machine (intel xeon core 2 duo
2.66ghz) running Suse linux for X86-64 with kernel 2.6.18.8-0.9

The same program is handled by clang without error messages on the
same machine running 32bit linux with the same kernel.
  
I use this to use gcc's headers:

Index: Driver/clang.cpp

Feel free to commit this patch; the whole thing is just a temporary
hack until clang gets its own standard headers anyway.

-Eli

Index: Driver/clang.cpp

--- Driver/clang.cpp (revision 47285)
+++ Driver/clang.cpp (working copy)
@@ -891,6 +891,8 @@
    AddPath("/usr/include", System, false, false, false, Headers);
    AddPath("/System/Library/Frameworks", System, true, false, true,
Headers);
    AddPath("/Library/Frameworks", System, true, false, true, Headers);
+ AddPath("/usr/lib/gcc/x86_64-linux-gnu/4.2.3/include", System,
+ false,false,false,Headers);
  }

Feel free to commit this patch; the whole thing is just a temporary
hack until clang gets its own standard headers anyway.

That's o.k., put please include a FIXME along with the commit.

snaroff

This hack hard codes gcc version 4.2.3 and target triplet. This hack opens door for multiple paths (each one for a unique combination of gcc version # and target triplet. Which could turn this into ugly hack very soon.

A better alternative is to use a clang configure time option that allows you to capture "/usr/lib/gcc/x86_64-linux-gnu/4.2.3/" as GCC_HEADERS_PATH and then add GCC_HEADERS_PATH/include here. A clang command line option to do the same would also work here, I guess.

I'm well aware that it's ugly... that said, once clang gets its own
standard headers, which will hopefully happen over the next few
months, we won't need those headers anymore, so it doesn't make much
sense to bother fixing it correctly.

-Eli

Devang Patel wrote:

This hack hard codes gcc version 4.2.3 and target triplet. This hack
opens door for multiple paths (each one for a unique combination of
gcc version # and target triplet. Which could turn this into ugly hack
very soon.

A better alternative is to use a clang configure time option that
allows you to capture "/usr/lib/gcc/x86_64-linux-gnu/4.2.3/" as
GCC_HEADERS_PATH and then add GCC_HEADERS_PATH/include here. A clang
command line option to do the same would also work here, I guess.

There is such a command-line option:
$ clang -isystem /usr/lib/gcc/x86_64-linux-gnu/4.2.3/include foo.c

So maybe that hack isn't needed after all.

--Edwin