GCC 16 Lands Better Support for -march= Targeting on RISC-V

2 hours ago 2

GNU

Merged on Friday for the GCC 16 compiler is better handling of the "-march=" compiler option on RISC-V systems when seeing multiple -march= hits and wanting to specify the RISC-V CPU name for targeting.

Robin Dapp of RISC-V CPU firm Ventana Micro Systems landed the improved -march= handling for the GCC compiler on the RISC-V architecture.

GCC RISC-V -march patch

Robin explained in the commit:

"This patch allows an -march string like

-march=sifive-p670

in order override a previous -march in a simple way.

Suppose we have a Makefile that specifies -march=rv64gc by default. A user-specified -mcpu=sifive-p670 would be after the -march in the options string and thus only set -mtune=sifive-p670 (as -mcpu does not override a previously specified -march or -mtune).

So if we wanted to override we would need to specify the full, lengthy -march=rv64gcv_... string instead of a simple -mcpu=...

Therefore this patch always first tries to interpret -march= as CPU string. If it is a supported CPU we use its march properties and let it override previously specified options. Otherwise the behavior is as before. This enables the "last-specified option wins" behavior GCC normally employs.

Note that -march does not imply -mtune like on x86 or other targets. So an -march=CPU won't override a previously specified -mtune=other-CPU."

This patch is merged to GCC Git for next year's GCC Git and will potentially be back-ported to the GCC 15 stable branch for a future point release in the coming months.

Read Entire Article