https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117563
Bug ID: 117563
Summary: RISC-V: -mcpu is ignored when -march has been
specified.
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: rdapp at gcc dot gnu.org
CC: kito.cheng at gmail dot com, law at gcc dot gnu.org,
palmer at dabbelt dot com, vineetg at rivosinc dot com
Target Milestone: ---
Target: riscv
As discussed yesterday, here's the bug for documentation and discussion
purposes.
When e.g. specifying -march=rv64gcv -mcpu=rv64gcv_zvl256b the zvl256b is
silently ignored because -march takes precedence over -mcpu.
This behavior is documented (invoke.texi) so we're behaving as specified:
"Note that @option{-mcpu} does not override @option{-march} or
@option{-mtune}."
I'd still argue that it is surprising to the user. It's often the case that a
Makefile sets a default -march in which case a manually specified -mcpu just
sets -mtune. (At least I hope it does)
IMHO better options are to:
- Combine/merge both options.
- Issue a warning.
- As -mcpu is basically -march + -mtune, have the rightmost one take precedence
over previous ones.
As Kito mentioned the strongest reason not to change anything is that LLVM has
the same behavior and we don't want to be incompatible.