Generate code for ARM Cortex m0, m3, and m4.


I am trying to cross compile code for ARM Cortex m0, m3, and m4.

For m0, I use:

   -target armv6--eabi -mcpu=cortex-m0

That seems to work. For m3 and m4, I use the following which does not work
(fatal error: error in backend: CPU: 'cortex-m3' does not support ARM mode):

  -target armv7m--eabi -mcpu=cortex-m3


  -target armv7em--eabi -mcpu=cortex-m4

Who can help me with the right command line arguments for m3 and m4?


Add -mthumb. It’s also probably a bug in the driver that that’s required. It should be implied by the v7m triple and/or cpu. Mind filing a PR to that effect?


Hi Jan,

For Cortex-M0, you should probably use the armv6m string in the target triple. For M3 and M4 you need to use the thumbv7m arch string, -mthumb won’t be necessary.


Yes, but I agree with Jim that a bug must be filled.

Jan, would you mind filling a bug?


I’ve got a trivial fix for this problem, and another one which manifests when thumb is given without an explicit CPU. I’ll start pushing it through our submissions process.

Thanks Bernie,

Feel free to assign yourself to the bug report, just so we know someone is working on it.


I see you already found it, but for others following along, this is