Bug 70210 - -march=native and -mcpu=native do not detect ARM cortex-a53 in 32 bit mode on Linux
Summary: -march=native and -mcpu=native do not detect ARM cortex-a53 in 32 bit mode on...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-12 10:14 UTC by Andrew Roberts
Modified: 2023-09-30 11:18 UTC (History)
4 users (show)

See Also:
Host: arm-linux-gnueabihf
Target: arm-linux-gnueabihf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-03-12 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Roberts 2016-03-12 10:14:25 UTC
When using -march=native or -mcpu=native with gcc-6-20160306 snapshot (and also on previous released versions), the ARM cortex-a53 CPU is not detected in 32 bit mode. This CPU is used on the Raspberry Pi 3 (BCM2834) amongst others.

Tested on Arch Linux ARM:

uname -a
Linux alarmpi 4.1.19-2-ARCH #1 SMP Sat Mar 5 22:22:01 MST 2016 armv7l GNU/Linux

cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 76.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : BCM2709
Revision        : a02082
Serial          : 00000000xxxxxxxx

/usr/local/gcc-6.0.0/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc-6.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-6.0.0/libexec/gcc/armv7l-unknown-linux-gnueab
ihf/6.0.0/lto-wrapper
Target: armv7l-unknown-linux-gnueabihf
Configured with: ../gcc-6.0.0/configure --prefix=/usr/local/gcc-6.0.0 --program-
suffix= --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix 
--with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptio
ns --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-un
ique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-insta
ll-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disab
le-multilib --disable-werror --enable-checking=release --host=armv7l-unknown-lin
ux-gnueabihf --build=armv7l-unknown-linux-gnueabihf --target=armv7l-unknown-linu
x-gnueabihf --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --disable
-bootstrap
Thread model: posix
gcc version 6.0.0 20160306 (experimental) (GCC) 

The CPU part table in gcc/config/arm/driver-arm.c does not include the cortex-a53 part number (0xd03).
Comment 1 Andrew Roberts 2016-03-12 10:48:21 UTC
Note this was causing bug 70132 (ARM -mcpu=native can cause a double free abort). 
A patch as been subitted to fix the double free, but doesn't address 
the failure to detect the CPU
Comment 2 ktkachov 2016-03-12 21:17:18 UTC
Confirmed.
Comment 3 Viktor Engelmann 2020-11-02 20:30:20 UTC
I see a (probably related) problem in gcc 9.3 on docker image alpine:latest on raspberry pi 3. There, Makefiles generated by autoconf pass -mcpu=armv7l.
And you can't just force it to use a different cpu by passing --host= to ./configure in your Dockerfile, because that would break the Dockerfiles' cross-platform compatibility. This breaks all autoconf projects in docker on raspberry pi 3.

This shouldn't be that hard IMHO, because -mcpu=armv7l only needs to be reinterpreted as -mcpu=cortex-a53.
Comment 4 ktkachov 2020-11-03 09:22:36 UTC
(In reply to Viktor Engelmann from comment #3)
> I see a (probably related) problem in gcc 9.3 on docker image alpine:latest
> on raspberry pi 3. There, Makefiles generated by autoconf pass -mcpu=armv7l.
> And you can't just force it to use a different cpu by passing --host= to
> ./configure in your Dockerfile, because that would break the Dockerfiles'
> cross-platform compatibility. This breaks all autoconf projects in docker on
> raspberry pi 3.
> 
> This shouldn't be that hard IMHO, because -mcpu=armv7l only needs to be
> reinterpreted as -mcpu=cortex-a53.

That's not correct usage though. -mcpu isn't documented to accepted architecture names (see https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/ARM-Options.html#ARM-Options for the accepted list of arguments accepted by mcpu/mtune)

There is the option -march that accepts architecture names, but armv7l isn't a valid architecture either. I'm not familiar with what Docker does here, but from the aarch32 GCC backend perspective the architecture for Cortex-A53 is -march=armv8-a+crc+simd

BTW, I believe the original bug in this report has been fixed for some time. All currently supported GCC versions (GCC 8.4 onwards) have the right part number for Cortex-A53
Comment 5 Viktor Engelmann 2020-11-03 15:02:19 UTC
Hmmm the problem isn't related to docker - I get the same problem when I run gcc on the raspberry directly with -mcpu=armv7l as autoconf does in docker.

When I run gcc manually with -mcpu=cortex-a53, everything is fine.
lscpu says

Architecture:        armv7l
Byte Order:          Little Endian
CPU(s):              4
On-line CPU(s) list: 0-3
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           1
Vendor ID:           ARM
Model:               4
Model name:          Cortex-A53
Stepping:            r0p4
CPU max MHz:         1200.0000
CPU min MHz:         600.0000
BogoMIPS:            38.40
Flags:               half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32

and /proc/cpuinfo is basically the same as the one Andrew Roberts had posted.
Maybe it's a problem in autoconf for passing armv7l (the "Architecture:" line) to -mcpu.
Comment 6 ktkachov 2020-11-03 15:34:10 UTC
(In reply to Viktor Engelmann from comment #5)
> Hmmm the problem isn't related to docker - I get the same problem when I run
> gcc on the raspberry directly with -mcpu=armv7l as autoconf does in docker.
> 

yep, armv7l is not a valid argument to -mcpu by design.

> When I run gcc manually with -mcpu=cortex-a53, everything is fine.
> lscpu says
> 
> Architecture:        armv7l
> Byte Order:          Little Endian
> CPU(s):              4
> On-line CPU(s) list: 0-3
> Thread(s) per core:  1
> Core(s) per socket:  4
> Socket(s):           1
> Vendor ID:           ARM
> Model:               4
> Model name:          Cortex-A53
> Stepping:            r0p4
> CPU max MHz:         1200.0000
> CPU min MHz:         600.0000
> BogoMIPS:            38.40
> Flags:               half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva
> idivt vfpd32 lpae evtstrm crc32
> 
> and /proc/cpuinfo is basically the same as the one Andrew Roberts had posted.
> Maybe it's a problem in autoconf for passing armv7l (the "Architecture:"
> line) to -mcpu.