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

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 12 08:15:36 PDT 2018


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.


More information about the llvm-dev mailing list