https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124629
Bug ID: 124629
Summary: [aarch64] -march=native reports wrong architecture
name with --help=target
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: Dhdreamer at 126 dot com
Target Milestone: ---
When running:
gcc -c -Q --help=target -march=native
on AArch64, the printed -march= value is empty, instead of showing the
expected architecture name such as "armv8-a" or "armv9-a".
The root cause is in gcc/config/aarch64/driver-aarch64.cc. The AARCH64_CORE
macro that populates aarch64_cpu_data[] uses `#ARCH` as the arch string
directly, producing values like "V8A". However, the AARCH64_ARCH macro that
populates aarch64_arches[] uses `#ARCH_IDENT + 1` to skip the leading "V"
prefix, producing values like "8A".
This inconsistency means that when the driver calls get_arch_from_id() to
look up the architecture name from aarch64_cpu_data[].arch (e.g., "V8A")
against aarch64_arches[].id (e.g., "8A"), the strcmp() never matches. The
lookup fails and returns NULL, so the -march= value in the output is empty.
The fix is to use `#ARCH + 1` in the AARCH64_CORE macro, consistent with
what AARCH64_ARCH already does.
Steps to reproduce:
1. Build GCC trunk for aarch64-linux-gnu
2. Run: gcc -c -Q --help=target -march=native
3. Observe the -march= line in the output
Expected: -march= shows the resolved architecture name, e.g. "armv8-a"
Actual: -march= is empty (blank) because the arch lookup fails
This does not affect code generation or ABI — only the reported name string.