[llvm-dev] beginner problem with cross compilation

Bruce Hoult via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 3 00:48:45 PST 2015


llc will make an object file with MIPS machine code for only the functions
in your test.bc. You then need to link it with any MIPS libraries it needs
(usually at least the C runtime library that calls main() for you etc).

The generated code will have exactly the data types (e.g. integer sizes)
and struct layouts specified in your test.bc. These might or might not be
correct for MIPS. If you're running on bare hardware then it's probably ok,
but if you call library functions then you need to be laying out the data
in the correct way. If you wrote test.bc yourself then that's your job, but
usually it's the job of e.g. clang, and you need to also tell clang that
you're compiling for MIPS (and which ABI) so it does that correctly.

A random .bc file for a similar enough machine might work -- same sizes,
same padding rules and so forth. But unless you know for sure those are the
same then chances are good that it won't work.


On Mon, Nov 2, 2015 at 11:37 PM, fateme Hoseini via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi everyone,
> I am a new commer and I 'm tying to use LLVM to cross compile a code. I
> want to cross compile to MIPS and the host is the default x86. The more I
> read the document the more confused I get. I see documents on
> cross-compiling to ARM. But some install some gcc packages, while some use
> clang. I don't know where to start and how to do it.
> Is this just enough to run a command line like this:
>
> llc -march=mips test.bc -o testmips
>
> will the testmips file be executable for mips?
> I will appreciate if anyone help me with this problem.
> Thanks,
> Fami
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151103/41d57978/attachment.html>


More information about the llvm-dev mailing list