Trying to compile llvm-gcc to mips

Hello, I’m trying to compile llvm-gcc to crosscompile mips. I have already modified a config.gcc to add mips as a target with llvm, but it gives me “Did not get a target machine!” (from llvm-backend.cpp).

I thought that I had to modify TargetMachOWriterInfo.h with MIPS info, but now the problem is that I don’t know where can I get the <mach/machine.h> (I don’t have it in /usr/include).

Any suggestions?

Thanks for helping a noob :wink:

Hi Julio,

Hello, I'm trying to compile llvm-gcc to crosscompile mips. I have already
modified a config.gcc to add mips as a target with llvm, but it gives me
"Did not get a target machine!" (from llvm-backend.cpp).

I thought that I had to modify TargetMachOWriterInfo.h with MIPS info, but
now the problem is that I don't know where can I get the <mach/machine.h> (I
don't have it in /usr/include).

Any suggestions?

Are you using the llvm-gcc top-of-tree(TOT) ? the TOT contains mips crosscompile
support, btw, you wont be able to pass through libgcc fp compile, which is what
I'm working right now.
What I suggest is that you begin the cross-compilation using llvm-gcc TOT, and
when it breaks, use cc1 directly to emit llvm bytecode specific for mips. Then,
use llc.
If you have doubts, just ask :slight_smile:

Hi, well, I downloaded the head revision of llvm and llvm-gcc. As you said it hangs at:

Formal argument #0 has unhandled type f32
/home/julio/trunk/llvm-gcc/gcc/libgcc2.c:1765: internal compiler error: Abortado
Please submit a full bug report,
with preprocessed source if appropriate.

Actually, I don’t need fp, there is any way to disable?

By the way, I’m working with a MIPS coprocessor with vectorial reconfigurable units (similar to RSVP). My future work will be autovectorize loops (I’ve already studied some code in LLVM and doesn seems very difficult, thanks to ScalarEvolution, LoopInfo, etc.). I was wondering about compiling newlib with gcc, compiling my code with llvm, and linking with the traditional ld, OR, compiling newlib with llvm, link my code and newlib (in llvm bitcode), and finally assemble to MIPS binary. With the second way, I could optimize functions like memcpy with vectorial instructions :).

The problem, is that in newlib there are c code mixed with MIPS assembler. I was wondering if configuring its compilation using llvm-gcc as CC and gnu-as as AS would work (linking the as files finally with ld and the result of the llvm assembler). In this way, with llvm-gcc working with -c and --emit-llvm command-options, would call gnu-as or llvm-as?

Thanks.
Julio

PD: My english isn’t as good as I wanted, so if you don’t understand me let me know.

2008/7/6 Bruno Cardoso Lopes <bruno.cardoso@gmail.com>:

And one last thing, the problem seems to be related to libcpp. Using only C frontend will work?

2008/7/7 Julio <julio.martin.hidalgo@gmail.com>:

Formal argument #0 has unhandled type f32
/home/julio/trunk/llvm-gcc/gcc/libgcc2.c:1765: internal
compiler error: Abortado
Please submit a full bug report,
with preprocessed source if appropriate.

I think an "export LC_ALL=C" cures the "Abortado" :slight_smile:

This looks like your host-compiler (e.g. what comes with your
Linux/BSD/MacOSX/xxxx-Distribution) has a bug. It cannot compile
this code. The best way for you would be to get this fixed.

If this is not feasible, sometimes you can look at the exact gcc
commandline, and run this commandline manually, but ommitting
the "-O2". Quite often the source can than be compiled.
Naturally this is just a band-aid ...

Also, have a look at the list of broken compilers:

http://llvm.org/docs/GettingStarted.html#brokengcc

Hi Julio,

And one last thing, the problem seems to be related to libcpp. Using only C
frontend will work?

The problem is with libgcc2, which contains libcalls needed to support
some operations
your processor cant directly do.

Actually, I don't need fp, there is any way to disable?

dunno how to disable

By the way, I'm working with a MIPS coprocessor with vectorial
reconfigurable units (similar to RSVP). My future work will be autovectorize
loops (I've already studied some code in LLVM and doesn seems very
difficult, thanks to ScalarEvolution, LoopInfo, etc.). I was wondering about
compiling newlib with gcc, compiling my code with llvm, and linking with the
traditional ld, OR, compiling newlib with llvm, link my code and newlib (in
llvm bitcode), and finally assemble to MIPS binary. With the second way, I
could optimize functions like memcpy with vectorial instructions :).

cool :slight_smile:

The problem, is that in newlib there are c code mixed with MIPS assembler.
I was wondering if configuring its compilation using llvm-gcc as CC and
gnu-as as AS would work (linking the as files finally with ld and the result
of the llvm assembler). In this way, with llvm-gcc working with -c and
--emit-llvm command-options, would call gnu-as or llvm-as?

with llvm-gcc crosscompiler ready you should have the (mips) gnu-as/ld called
automatically by gcc (as long as they are identified by 'configure')
I haven't tried to compile newlib yet (I'll will in the near feature),
if it breaks
send me the bugs with testcases and I'll try to fix it for you. The mips
BE is still under heavy devel, so I dunno if it will perfectly fit your needs.
Anyway, I can help you with the bugs! :slight_smile:

The problem is with libgcc2, which contains libcalls needed to support
some operations
your processor cant directly do.

Yes, I mix up libgcc2 with libcpp… I have advanced a little, commenting out the fp functions. Now, it stucks at unwind-dw2.c. MipsISelLowering.cpp gives the error: Unsupported calling convention.

By the way, I understand that these functions are treated by LLVM like built-in functions, and MipsISelLowering purpose is to match the arguments and return types?

Any idea of which function can be?

Thanks for all.

2008/7/8 Julio <julio.martin.hidalgo@gmail.com>:

The problem is with libgcc2, which contains libcalls needed to support
some operations
your processor cant directly do.

Yes, I mix up libgcc2 with libcpp… I have advanced a little, commenting out the fp functions. Now, it stucks at unwind-dw2.c. MipsISelLowering.cpp gives the error: Unsupported calling convention.

By the way, I understand that these functions are treated by LLVM like built-in functions, and MipsISelLowering purpose is to match the arguments and return types?

Any idea of which function can be?

Thanks for all.

Finally I commented out all the dward code jeje. Also, I had to eliminate c++ cause libstdc++ was making noise, libssp, llsc, … but finally, I have a llvm-gcc for mips :smiley: (how slowly compiles gcc…)

Thanks for all your help, Bruno.