I get the following warning:
-mcpu=cortex-r5 conflicts with -march=armv7-r switch
When I set -mcpu to cortex-r4 or cortex-r4f I do not get the problem. As the Cortex R5 is the same armv7-r architecture I am assuming this is a bug in the GCC toolchain? I am currently using the Arm Launchpad 5.4 2016q3 tools.
I am also wondering why there is not a Cortex-r5f option as the floating point unit is optional.
I am guessing that the -mcpu
options does not really make a lot of difference?
I am guessing that the
-mcpu
options does not really make a lot of difference?
Yes, this is more than correct. The -mcpu
option superseded the -march
; it is more specific. For the cortex-r4, it is a minimal cortex-r system, so it is basically the synonymous with -march=armv7-r
. You can idealize at -mcpu=xxx
as both -march=xxx
and -mtune=xxx
. There are some systems where 'x' and 'y' may each have unique features. But the for cortex-r, the cortex-r4 is the minimum. This explains observed (correct) behaviour.
Even in present day, the error still pesists.
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:10.3-2021.07-4) 10.3.1 20210621 (release)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ cat test.c
/*@
ensures \result >= 0;
ensures x < 0 ==> \result == -x;
ensures x >= 0 ==> \result == x;
*/
int abs(int x)
{
if (x < 0)
return -x;
else
return x;
}
$ arm-none-eabi-gcc -Wall -mcpu=cortex-r5 -march=armv7-r -O3 -c -o test.o test.c
cc1: warning: switch '-mcpu=cortex-r5' conflicts with '-march=armv7-r' switch
As I said in the comments, the correct option is -mtune
.
$ arm-none-eabi-gcc -Wall -mtune=cortex-r5 -march=armv7-r -O3 -c -o test.o test.c
Here you generate code for any cortex-r system, but it will be optimized for a cortex-r5. If you really want to target only the cortex-r5, then use ONLY the -mcpu=cortex-r5
option. The code will be slightly better. However, often you use 3rd party libraries and sometimes they are closed source and compiled with some other flags (many question here on SO on this topic). Using -march
will also allow you more possibilities to use 3rd party closed source as well.
You should be able to link -mcpu=cortex-r5
with -march=armv7-r
code; well it is fine in one directions, so the tools may complain. You could get around this... but that is not the question.