Failure to compile llvm-gcc-4.2-2.7 on FreeBSD on sparc machine

llvm itself compiles fine.
gcc frontend has the error, see below.

I applied the attached patch, since the name of architecture on FreeBSD is sparc64, not sparc. There is also one more replacement sparc -> spaarc64 was made in gcc/Makefile in llvm-gcc.

FreeBSD -8.0-STABLE
gcc-4.5.0
sunblade 100

Yuri

gmake[2]: Leaving directory `/tmp/llvm-build/2.7/llvm-gcc-4.2-objects/libdecnumber'
gmake[2]: Entering directory `/tmp/llvm-build/2.7/llvm-gcc-4.2-objects/gcc'
/tmp/llvm-build/2.7/llvm-gcc-4.2-objects/./gcc/xgcc -B/tmp/llvm-build/2.7/llvm-gcc-4.2-objects/./gcc/ -B/usr/local/llvm/2.7/sparc64-unknown-freebsd8.0/bin/ -B/usr/local/llvm/2.7/sparc64-unknown-freebsd8.0/lib/ -isystem /usr/local/llvm/2.7/sparc64-unknown-freebsd8.0/include -isystem /usr/local/llvm/2.7/sparc64-unknown-freebsd8.0/sys-include -O2 -O2 -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -I. -I. -I../../llvm-gcc-4.2/gcc -I../../llvm-gcc-4.2/gcc/. -I../../llvm-gcc-4.2/gcc/../include -I./../intl -I../../llvm-gcc-4.2/gcc/../libcpp/include -I/usr/local/include -I../../llvm-gcc-4.2/gcc/../libdecnumber -I../libdecnumber -I/tmp/llvm-build/2.7/llvm-gcc-4.2-objects/../llvm-objects/include -I/tmp/llvm-build/2.7/llvm/include -g0 -finhibit-size-directive -fno-inline-functions -fno-exceptions -fno-zero-initialized-in-bss -fno-toplevel-reorder \
          -c ../../llvm-gcc-4.2/gcc/crtstuff.c -DCRT_BEGIN \
          -o crtbegin.o
GCC: <pointer_type 0x41a1b130
    type <void_type 0x41a1b080 void VOID
        align 8 symtab 1 alias set -1
        LLVM: void
        pointer_to_this <pointer_type 0x41a1b130>>
    public unsigned DI
    size <integer_cst 0x41a08b70 type <integer_type 0x41a1a0b0 bit_size_type> constant invariant 64>
    unit size <integer_cst 0x41a08ba0 type <integer_type 0x41a1a000 long unsigned int> constant invariant 8>
    align 64 symtab 0 alias set -1
    pointer_to_this <pointer_type 0x41a2cbb0>>
LLVM: i8* (32 bits)
LLVM type size doesn't match GCC type size!../../llvm-gcc-4.2/gcc/crtstuff.c:267: internal compiler error: in llvm_set_type, at llvm-types.cpp:89
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://llvm.org/bugs/> for instructions.

llvm-patch-sparc64.diff (2.22 KB)

Hello

I applied the attached patch, since the name of architecture on FreeBSD is
sparc64, not sparc. There is also one more replacement sparc -> spaarc64 was
made in gcc/Makefile in llvm-gcc.

The patch is incorrect and the problems you're seeing are caused by
your patch, since sparc != sparc64.
In LLVM sense "sparc" means "sparc with ILP32 architecture model",
llvm does not support anything 64 bit in sparc world.

size <integer_cst 0x41a08b70 type <integer_type 0x41a1a0b0 bit_size_type>
constant invariant 64>
unit size <integer_cst 0x41a08ba0 type <integer_type 0x41a1a000 long
unsigned int> constant invariant 8>
align 64 symtab 0 alias set -1
pointer_to_this <pointer_type 0x41a2cbb0>>
LLVM: i8* (32 bits)
LLVM type size doesn't match GCC type

Indeed, LLVM assumes that pointer size is 32 bits (since it's 32 bit
sparc), but gcc - definitely not.

So LLVM support for sparc64 has to be implemented I guess.

Yes.

Is this work started?

I am not aware about any significant sparc-related works during past
few years. So, the answer is most probably "no".

Anton Korobeynikov wrote:

The patch is incorrect and the problems you're seeing are caused by
your patch, since sparc != sparc64.
In LLVM sense "sparc" means "sparc with ILP32 architecture model",
llvm does not support anything 64 bit in sparc world

SparcTargetMachine.h file lists SparcV9TargetMachine as 64-bit machine and SparcV8TargetMachine as 32-bit machine.
And SparcInstrInfo.td seems to contain some of the V9-only instructions.

Are you sure 64-bit sparc isn't supported at all?

Yuri

SparcTargetMachine.h file lists SparcV9TargetMachine as 64-bit machine and
SparcV8TargetMachine as 32-bit machine.
And SparcInstrInfo.td seems to contain some of the V9-only instructions.

Are you sure 64-bit sparc isn't supported at all?

Ah, sorry, I was looking into wrong sources - too much different LLVM
trees around :slight_smile: It seems that someone already provided 64 bit target
data.

In this case you probably need to add proper "sparc64" target triple
recognition code, then make sure that 64 bit subtarget is selected and
fix all the sparc codegen bugs you'll see on the way (I'd expect
plenty of them since sparc backend is unmaintained).