problem with lli (llvm 1.3)

Hi,

I am working with llvm 1.3 on a sparcv9 machine. I have successfully built
llvm and llvm-gcc frontend. I can run many tools including llvmgcc,
llvm-dis, and llc. After using /opt/SUNWspro/bin/cc to assemble .s file
into a program binary, I can run the binary correctly as well.

I am interested in the JIT compiler (lli). When I directly run the
LLVM bytecode using interpretation ("lli -force-interpreter=true test.bc),
it works fine. But if I use the JIT compiler ("lli
-force-interpreter=false test.bc"), I got a Segmentation Fault error,
even for a small program like helloworld.

If running with gdb, the error looks like

Is your compiler configured to define __sparcv9 when it compiles?
The following should tell you:

% touch /tmp/file.c
% gcc -dM -E /tmp/file.c | grep __sparcv9

If the output is similar to the below, you're fine:
#define __sparcv9 1

If the above command gives no output, then you need to specify -mcpu=v9
or reconfigure/recompile GCC to default to outputting V9 code.

Thanks Misha. I tried the "gcc -dM -E /tmp/file.c | grep __sparcv9" but
there was no output. Maybe this is the probelm, I do have

CXX = g++ -mcpu=v9

in the Makefile.config. Do I need to add -m64 as well? Thanks.

Shukang

Thanks Misha. I tried the "gcc -dM -E /tmp/file.c | grep __sparcv9"
but there was no output. Maybe this is the probelm, I do have

CXX = g++ -mcpu=v9
CC := gcc -mcpu=v9

in the Makefile.config. Do I need to add -m64 as well? Thanks.

Just run the test that I mentioned before:

I'm sorry, I did not completely understand your email, let me clarify my
response.

Thanks Misha. I tried the "gcc -dM -E /tmp/file.c | grep __sparcv9"
but there was no output. Maybe this is the probelm, I do have

CXX = g++ -mcpu=v9
CC := gcc -mcpu=v9

in the Makefile.config. Do I need to add -m64 as well? Thanks.

Just run the test that I mentioned before:

> % touch /tmp/file.c
> % gcc -mcpu=v9 -dM -E /tmp/file.c | grep __sparcv9

          ^^^^^^^^ you need to specify that here <====== correction

>
> If the output is similar to the below, you're fine:
> #define __sparcv9 1

If the above command gives no output, then try again, specifying -m64.

The key is to get __sparcv9 #defined, because there is code in the
SparcV9 JIT that is conditionally compiled based on it.

If none of the above define __sparcv9, what is the output of the
following?

% gcc -dumpmachine

Thanks Misha. I tried the experiment again. "gcc -mcpu=v9 ..." doesn't
have output. However, using "gcc -mcpu=v9 -m64 ..." has the same output as
what you pointed out. I am rebuilding LLVM now, and hope this solves the
problem. :slight_smile: Thanks again.

Shukang