Keil Logo

Mandatory armclang options

2.1 Mandatory armclang options

When using armclang, you must specify a target on the command-line. Depending on the target you use, you might also have to specify an architecture or processor.

Specifying a target

To specify a target, use the --target option. The following targets are available:

  • To generate A64 instructions for AArch64 state, specify --target=aarch64-arm-none-eabi.

    Note:

    For AArch64, the default architecture is Arm®v8‑A.
  • To generate A32 and T32 instructions for AArch32 state, specify --target=arm-arm-none-eabi. To specify generation of either A32 or T32 instructions, use -marm or -mthumb respectively.

    Note:

    AArch32 has no defaults. You must always specify an architecture or processor.

Specifying an architecture

To generate code for a specific architecture, use the -march option. The supported architectures vary according to the selected target.

To see a list of all the supported architectures for the selected target, use -march=list.

Specifying a processor

To generate code for a specific processor, use the -mcpu option. The supported processors vary according to the selected target.

To see a list of all the supported processors for the selected target, use -mcpu=list.

It is also possible to enable or disable optional architecture features, by using the +[no]feature notation. For a list of the architecture features that your processor supports, see the processor product documentation. See the Arm Compiler Reference Guide for a list of architecture features that Arm Compiler supports.

Use +feature or +nofeature to explicitly enable or disable an optional architecture feature.

Note:

You do not need to specify both the architecture and processor. The compiler infers the architecture from the processor. If you only want to run code on one particular processor, you can specify the specific processor. Performance is optimized, but code is only guaranteed to run on that processor. If you want your code to run on a range of processors from a particular architecture, you can specify the architecture. The code runs on any processor implementation of the target architecture, but performance might be impacted.

Specifying an optimization level

The default optimization level is -O0, which does not apply any optimizations. Arm recommends that you always specify a suitable optimization level. For more information, see Selecting optimization options in the Arm® Compiler User Guide, and see the -O option in the Arm® Compiler Reference Guide.

Examples

These examples compile and link the input file helloworld.c:

  • To compile for the Armv8‑A architecture in AArch64 state, use:
    armclang --target=aarch64-arm-none-eabi -march=armv8-a helloworld.c
  • To compile for the Armv8‑R architecture in AArch32 state, use:
    armclang --target=arm-arm-none-eabi -march=armv8-r helloworld.c
  • To compile for the Armv8‑M architecture mainline profile, use:
    armclang --target=arm-arm-none-eabi -march=armv8-m.main helloworld.c
  • To compile for a Cortex®‑A53 processor in AArch64 state, use:
    armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a53 helloworld.c
  • To compile for a Cortex‑A53 processor in AArch32 state, use:
    armclang --target=arm-arm-none-eabi -mcpu=cortex-a53 helloworld.c
  • To compile for a Cortex-M4 processor, use:
    armclang --target=arm-arm-none-eabi -mcpu=cortex-m4 helloworld.c
  • To compile for a Cortex-M33 processor, with DSP disabled, use:
    armclang --target=arm-arm-none-eabi -mcpu=cortex-m33+nodsp helloworld.c
  • To target the AArch32 state of an Arm Neoverse™ N1 processor, use:
    armclang --target=arm-arm-none-eabi -mcpu=neoverse-n1 helloworld.c
  • To target the AArch64 state of an Arm Neoverse E1 processor, use:
    armclang --target=aarch64-arm-none-eabi -mcpu=neoverse-e1 helloworld.c
Non-ConfidentialPDF file icon PDF version100748_0614_00_en
Copyright © 2016–2020 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.