[llvm-dev] Cross-compiling for ARM Cortex-M3 on x86

Son Tuan VU via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 12 08:35:29 PDT 2018


Thanks for your prompt reply.

I didn't build the libc at all, I downloaded a pre-built version of the
whole toolchain from
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads, so I
guess it is an official version provided by ARM and should work? This
version targets ARM Cortex-M and Cortex-R family of processors...

Son Tuan Vu

On Mon, Mar 12, 2018 at 4:15 PM, Tim Northover <t.p.northover at gmail.com>
wrote:

> Hi,
>
> On 12 March 2018 at 15:06, Son Tuan VU via llvm-dev
> <llvm-dev at lists.llvm.org> wrote:
> > But libc code is in ARM mode:
>
> That's very bad, because Cortex-M doesn't support ARM mode. I think
> your libc is broken.
>
> > As you can see, the call to srand is just a bl (Branch with Link), not a
> blx
> > (Branch with Link and Exchange instruction set), so I think something is
> > going wrong here.
>
> Yes, Cortex-M has no blx instruction.
>
> > Can anyone kindly give me some pointers on how to debug this? Or at least
> > tell me whether this is a bug?
>
> You don't mention how you build libc, but that's what you need to fix.
>
> > I am a bit lost now, I've tried to look up
> > for more information on this but cannot find out why Clang doesn't
> generate
> > Thumb code for libc functions.
>
> It'll be part of your libc's build system (Makefile?). Clang should
> simply refuse to produce ARM mode code if it knows it's targeting
> Cortex-M, so my guess is no -mcpu option is being specified. There
> might be subtle differences in how GCC has been compiled that means
> your version defaults to Thumb mode anyway, but Clang doesn't.
>
> Cheers.
>
> Tim.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180312/9d8586f9/attachment.html>


More information about the llvm-dev mailing list