[LLVMdev] Compiling MiBench to MIPS

Tim Northover t.p.northover at gmail.com
Tue May 27 10:28:23 PDT 2014


Hi Ronaldo,

On 27 May 2014 18:13, Ronaldo Ferreira <ronaldorferreira at gmail.com> wrote:
> clang -static -O3 basicmath_small.c rad2deg.c cubic.c isqrt.c -c -emit-llvm
> llvm-link basicmath_small.bc rad2deg.bc cubic.bc isqrt.bc -o basicmath.bc
> llc basicmath.bc -march=mipsel -relocation-model=static -o basicmath

My best guess is that the LLVM IR created on line 1 is actually for
x86-64 (generated by a Clang targeting x86-64, having included x86-64
headers and so on). When you override the output target on the third
line, you would end up feeding the MIPS backend IR that it's not
equipped to deal with. Clang's output *does* depend on what it's
targeting.

If so, you need to create a proper cross-development environment for
MIPS (binutils, libc, headers, ...) and point clang at it in the first
line (via -target and -sysroot at least, possibly other options too;
getting the driver to work properly can be a tricky business. Use "-v"
to get it to tell you more about what it's trying to do). Then the
later lines should work fine (though you won't need the -march option
for llc).

Cheers.

Tim.

P.S. The backends probably shouldn't crash regardless, but the reality
is that they're adapted to the kind of IR Clang produces when it knows
it's targeting them and other configurations are much less
well-tested. Since the alternative is successfully generating wrong
code, it's not much of a priority for me at least.



More information about the llvm-dev mailing list