[LLVMdev] Compiling MiBench to MIPS
Ronaldo Ferreira
ronaldorferreira at gmail.com
Tue May 27 11:09:33 PDT 2014
Thanks Tim, I was not aware of that issue with clang. I could compile with:
clang --target=mips-linux-gnu
--sysroot=/home/ronaldo/CodeSourcery/Sourcery_CodeBench_Lite_for_MIPS_GNU_Linux
-static -O3 basicmath_small.c rad2deg.c cubic.c isqrt.c -c -emit-llvm
I already had the MIPS toolchain installed.
2014-05-27 19:28 GMT+02:00 Tim Northover <t.p.northover at gmail.com>:
> 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.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140527/df63b9e7/attachment.html>
More information about the llvm-dev
mailing list