Using Arm Compiler 6 with CPAKs
Introduction
The CPAKs for the Arm Cortex-A57 and Cortex-A53 processors demonstrate 64-bit bare metal software examples which can be modified and compiled with DS-5 using Arm Compiler 6.
Arm Compiler 6 is based on Clang and the LLVM Compiler Framework, and provides best in class code generation for the Arm Architecture. Compiler 6 is based on open source which has a flexible license and allows commercial products to be created without making the source code available.
Migration Guide
To better understand the differences between armcc and armclang, take a look at the Arm Compiler Migration Guide. It explains the command line differences between the two compilers and how to map switches from the old compiler to the new compiler. The migration guide also covers two additional tools provided to aid in switching compilers:
- Source Compatibility Checker
- Command-line Translation Wrapper
The compatibility checker helps find issues in the source code that is being migrated, while the translation wrapper provides an automatic way to call armcc as before, but invisibly calls armclang with the equivalent options. Migration will involve new compiler invocation and switches, but it may also involve source code changes for things such as pragmas and attributes that are different between the compilers.
Using Compiler 6 on a Cortex-A53 CPAK
For this example the DecrDataMP_v8/ example in the Applications/ directory of the CPAK has been selected. The system is a dual-cluster Cortex-A53 where each cluster has 1 core. It also includes the CCI-400 to demonstrate cache coherency between clusters and the NIC-400 for connecting peripherals. The block diagram is shown below.
To set up DS-5 use Linux and bash to add the bin/ directory of DS-5 to the relevant PATH environment variable. Adjust the path to match your installation:
$ export PATH=$PATH:/o/tools/linux/ARM/DS5_5.<version>/64bit/bin, where <version> is replaced by the version of DS-5 installed.
NOTE: Only the 64-bit version of DS-5 includes Arm Compiler 6, it’s not included in the 32-bit version of DS-5.
- The first step to using Arm Compiler 6 is to edit the Makefile and replace armcc with armclang to compile the C files. Any assembly files can continue to be compiled by armasm and linking done with armlink remains mostly the same. It is possible to compile assembly files and link with armclang, but for this case I decided to leave the flow as is to learn the basics of making the compiler transition.
- The next important change is the specification of the target CPU. With armcc the --cpu option is used. You will see --cpu=8-A.64.no_neon in the Makefile. One tip is to use the command below to get a list of possible targets.
- With armclang the target CPU selection is done using the -target option. To select AArch64 use -target aarch64-arm-none-eabi in place of the --cpu option.
The Makefile specifies the compiler as the CC variable so make it CC=armclang
$ armcc --cpu list
The invocation command and the target CPU selection are the main differences needed to switch from armcc to armclang.
Other Switches
- The selected CPAK software is using –-c90 to specify the version of the C standard to use. For armclang the equivalent option is –xc –std=c90 so make this change in the Makefile also.
- The next issue is the use of –-dwarf3 option. This is not supported by armclang and it seems like DWARF4 is the only option with armclang.
- The Makefile also uses –Ospace as an option to shrink the program size at the possible expense of runtime speed. For armclang this should be changed to –Os.
- The last difference relates to armlink. The armlink commands need --force_scanlib to tell armlink to include the Arm libraries. From the documentation, this option is mandatory when running armlink directly. Add this flag to the armlink commands and the compilation will complete successfully and generate .axf files.
Here is a table summarizing the differences:
Arm Compiler 5 |
Arm Compiler 6 |
Invoke using armcc |
Invoke using armclang |
--cpu=8-A.64.no_neon |
-target aarch64-arm-none-eabi |
--dwarf3 |
None |
-Ospace |
-Os |
|
--force_scanlib |
Creating an Eclipse Project for DS-5
To compile the example, use the eclipse environment in DS-5. The following guide uses a new Makefile project:
- First, launch eclipse using
$ eclipse & - Once eclipse is started, use the menu File -> New -> Makefile Project with Existing Code
- Pick a name for the a project and fill it into the dialog box, browse to the location of the code, and select Arm Compiler 6 as the Toolchain for indexer settings.
- Once the project is setup use the Project menu item called Build Project to compile the code.
This article was originally written as a blog by Jason Andrews. Read the original post on Connected Community.