[cfe-dev] Compiling ARM code at an architecture level

Meador Inge meadori at gmail.com
Tue Feb 10 08:43:28 PST 2015


Hi All,

I am working on a problem where it does not seem possible to
compile code for ARM at an architecture level.  For example,
compiling:

  $ clang -target arm-none-eabi -mthumb -march=armv7 -o - -S test.c | grep
'\.cpu'
      .cpu cortex-a8

However, I don't want the code locked to a Cortex-A8 CPU.  In fact, for
this particular
example it can cause problems because I would like to create an ARMv7 Thumb
static
library that can be used with both ARMv7 A and M profiles.

GCC has logic to produce a .arch directive when -march is used:

  $ arm-none-eabi-gcc -mthumb -march=armv7 -S -o - test.c | grep '\.cpu'
  $ arm-none-eabi-gcc -mthumb -march=armv7 -S -o - test.c | grep '\.arch'
      .arch armv7

I would like similar behavior in Clang.

>From working through the various toolchains and options in the driver code I
see two immediate approaches:

   1. When -mcpu is not specified, don't generate -target-cpu for the CC1
invocation
       and derive the architecture information from the triple (I did find
it somewhat
       surprising the architecture version info in embedded in the
triple).  Wether or
       not the CPU string is empty will detail if .cpu or .arch should be
generated.

   2. Add driver support for the GCC ARM -mcpu=generic-arch option form.
Then
       we can still always generate -target-cpu still and make decisions on
whether
       to generate .cpu or .arch from the "generic-" part.

Have other run into this and consider it a problem?  Other solutions?

-- Meador
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150210/61d41fff/attachment.html>


More information about the cfe-dev mailing list