GCC -march -mcpu options for the FU740-C000

I’m in the middle of setting flags for the GCC compiler in the Gentoo installer right now and looking through documentation for the SoC, am I correct in doing =march=rv64gc -mcpu=sifive-u74?

and if I potentially want to target the S7 all i need to do is to compile for =march=rv64imac -mcpu=sifive-s7 ?

-mcpu sets both -march and -mtune. So using both march and mcpu is not necessary unless you don’t want the default arch specified by mcpu. march chooses the architecture extensions that are enabled. mtune chooses the instruction latencies and pipeline model used by the instruction scheduler.

To see what -mcpu does, you can run gcc with -v to see the options passed to cc1. So if I do this

touch tmp.c
riscv64-unknown-linux-gnu-gcc -mcpu=sifive-u74 -v -S tmp.c

Then I see in the -v output

/home/jimw/FOSS/install-riscv64/libexec/gcc/riscv64-unknown-linux-gnu/11.1.0/cc1 -quiet -v tmp.c -quiet -dumpbase tmp.c -dumpbase-ext .c -mcpu=sifive-u74 -mtune=sifive-7-series -march=rv64imafdc -mabi=lp64d -march=rv64imafdc -version -o tmp.s

and you can see that -mcpu was expanded to -march and -mtune options.

sifive-s7 expands to march=rv64gc mtune=sifive-7-series so you would need to use a march option in that case to get rv64imac.

If you know what arch and tune you want, then it may be simpler to avoid mcpu and use march and mtune directly.

You can also see what mcpu does by looking at the source file for it.
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/riscv/riscv-cores.def;h=bf5aaba49c3898f2445132568e89e27ff21355fc;hb=HEAD

cool thanks!