GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
risc-v

RISC-V: Pass detected core with -mcpu=native

RISC-V's -mcpu=native now correctly passes the detected core name to the compiler driver.

The RISC-V compiler driver now correctly passes the detected CPU core name when using the -mcpu=native option. Previously, -mcpu=native expanded to -march= -mtune=, and the compiler itself (cc1) never saw the -mcpu option. This change ensures that per-core settings, such as errata workarounds, are correctly applied by passing -mcpu= alongside -march.

In Details

The RISC-V driver historically mapped -mcpu=native to -march=<ISA> -mtune=<core>. This commit modifies the driver to also pass -mcpu=<core> when the host CPU is detected. This preserves per-core tuning and errata information that would otherwise be lost because cc1 would not see the original -mcpu option. The -march flag still takes precedence for ISA selection.

For Context
-mcpu=native
A GCC command-line option that instructs the compiler to detect the host CPU's architecture and tune code generation for it. For RISC-V, it now also explicitly passes the detected core name.
-march
A GCC command-line option specifying the target RISC-V architecture (ISA extension set).
-mtune
A GCC command-line option specifying the target CPU for code optimization, without changing the ISA. Affects instruction scheduling and other microarchitectural tuning.
cc1
The primary C compiler front-end executable in GCC. It parses C source code and generates intermediate representation (IR).
driver
The GCC driver program (e.g., gcc) that orchestrates the compilation process, invoking various tools like the preprocessor, compiler front-ends, assembler, and linker.
Filed Under: risc-vcompiler drivercpu detection