VOOZH about

URL: https://www.phoronix.com/news/GCC-16-Better-march-RISC-V

⇱ GCC 16 Lands Better Support For -march= Targeting On RISC-V - Phoronix


👁 Phoronix

GCC 16 Lands Better Support For -march= Targeting On RISC-V

Written by Michael Larabel in GNU on 24 May 2025 at 05:30 AM EDT. 1 Comment
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.

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.