llvm-gcc is generating native code

Hello,

I downloaded llvm-gcc4.2-2.2.source.tar.gz and followed instructions in README.LLVM, I used this to configure it:

…/configure --prefix=/opt/llvm --enable-threads --disable-nls --enable-languages=c,c++ --enable-sjlj-exceptions --enable-llvm=/home/kashyapa/llvm-2.2 --program-prefix=llvm- --disable-bootstrap

I have already installed llvm-2.2 in /opt/llvm.

The compilation goes thru fine. /opt/llvm/bin/llvm-gcc –v, prints this:

Using built-in specs.

Target: i686-pc-linux-gnu

Configured with: …/configure --prefix=/opt/llvm --enable-threads --disable-nls --disable-shared --enable-languages=c,c++ --enable-sjlj-exceptions --enable-llvm=/opt/llvm/ --program-prefix=llvm- --disable-multilib --disable-bootstrap : (reconfigured) …/configure --prefix=/opt/llvm --enable-threads --disable-nls --disable-shared --enable-languages=c,c++ --enable-sjlj-exceptions --enable-llvm=/home/kashyapa/llvm-2.2 --program-prefix=llvm- --disable-multilib --disable-bootstrap

Thread model: posix

gcc version 4.2.1 (Based on Apple Inc. build 5546) (LLVM build)

When I compile using this compiler, I do not get a *.bc file. Instead the binary generated seems to be a i386 binary. I also made sure /opt/llvm/bin is in path and LD_LIBRARY_PATH=/opt/llvm/lib

I am using Ubuntu and have also uninstalled the stock (old v1.8, but generates *.bc correctly) llvm that is shipped.

Is there anything I missed?

Thanks,

Ashwin

Hi, Ashwin,

     I think what you want is to add -emit-llvm after llvm-gcc, like:

$> llvm-gcc foo.c -o foo.bc -c -emit-llvm

Fernando

Or you can pass -O4, which is -O3 + -emit-llvm.

-Chris

Hello,
I downloaded llvm-gcc4.2-2.2.source.tar.gz and followed instructions in README.LLVM, I used this to configure it:
…/configure --prefix=/opt/llvm --enable-threads --disable-nls --enable-languages=c,c++ --enable-sjlj-exceptions --enable-llvm=/home/kashyapa/llvm-2.2 --program-prefix=llvm- --disable-bootstrap

I have already installed llvm-2.2 in /opt/llvm.
The compilation goes thru fine. /opt/llvm/bin/llvm-gcc –v, prints this:

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: …/configure --prefix=/opt/llvm --enable-threads --disable-nls --disable-shared --enable-languages=c,c++ --enable-sjlj-exceptions --enable-llvm=/opt/llvm/ --program-prefix=llvm- --disable-multilib --disable-bootstrap : (reconfigured) …/configure --prefix=/opt/llvm --enable-threads --disable-nls --disable-shared --enable-languages=c,c++ --enable-sjlj-exceptions --enable-llvm=/home/kashyapa/llvm-2.2 --program-prefix=llvm- --disable-multilib --disable-bootstrap
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5546) (LLVM build)

When I compile using this compiler, I do not get a *.bc file. Instead the binary generated seems to be a i386 binary. I also made sure /opt/llvm/bin is in path and LD_LIBRARY_PATH=/opt/llvm/lib

The interface of llvm-gcc is like gcc: by default it compiles as far as a.out, and stops earlier with -c or -S.
You need -emit-llvm -c to get an llvm binary file; -emit-llvm -S produces the ASCII form. The name defaults to *.s or *.o as usual for -c and -S, and is changed with -o as usual.

> $> llvm-gcc foo.c -o foo.bc -c -emit-llvm

Or you can pass -O4, which is -O3 + -emit-llvm.

This seems to have stopped working recently
(4.2 from svn).

D.