Safe CFlags - GCC 12.2.1

Dear all,

I’ve installed Gentoo on the Vision 2 Board and playing around with CFLAGS and ggc 12.2.1.

I think this are the correct one - or did anyone have different infos?

CFLAGS="-mabi=lp64d
-march=rv64imafdc_zicsr -mcpu=sifive-u74 -mtune=sifive-u74
-O2 -pipe -fomit-frame-pointer 
--param l1-cache-size=32 --param l2-cache-size=2048"
1 Like

I use this to build Python 3.11.1

CFLAGS="-march=rv64imafdc -mcpu=sifive-u74 -mtune=sifive-7-series"
2 Likes

You probably already know this, but if not you can look at what you’re getting without special tuning with:

gcc -march=native -E -v - </dev/null 2>&1 | grep cc1

The bitmap extension is available for StarFive2 CPUs.
I use -march=rv64imafdczbb0p93_zba0p93 as a compiler option.
When I tried it with a program that uses bitmaps (Shogi, Japanese Chess), there was a 5% performance improvement.

3 Likes

I think -march=native is not supported in RISC-V yet. Your command without grep showing this:

gcc: error: ‘-march=native’: ISA string must begin with rv32 or rv64

do we need to specify 0.93 for b extension? just asking because clang seem to refuse it, but allow just _zba_zbb.

1 Like

Thank you very much for your hint :pray:. If we use your -march flag, then there is a noticeable improvement in my nbench benchmark (left with your march, right with the old one).

So I recommended as safe CFLAGS:

CFLAGS="-mabi=lp64d
-march=rv64imafdczbb0p93_zba0p93 -mcpu=sifive-u74 -mtune=sifive-7-series
-O2 -pipe -fomit-frame-pointer 
--param l1-cache-size=32 --param l2-cache-size=2048"
6 Likes

you are correct.
I tried with clang first, so I gave it 0.93. Not required for gcc.

3 Likes

I will try to rebuild my Python with this CFLAGS, very excited to get things faster on this CPU.

3 Likes

What Document/Process did you follow to install Gentoo on this Board?

There is a install guide for a raspberry. you can follow this guide (Raspberry Pi/Quick Install Guide - Gentoo Wiki). Grab the modules (/lib/modules) and boot partition from starfive debian image.

You can use the risc v autobuilds: Index of /pub/Mirrors/gentoo/releases/riscv/autobuilds

If you install / compile all time, my recommendation: use a fan or a heatsink

Did you have to use the Serial Port or did it work via the HDMI port?

Hi, I tried Gentoo MUSL stage3 autobuild, but it hangs on boot without any error, the board seems to reset. Anyone tried musl one?

1 Like

Normal gentoo rootfs also hangs for me on Starting Local.

Only serial and ssh access. you can possibly install the gfx binary driver but i didn’t try.

@riley10 maybe you didn’t configure your serial on the visionfive side. Normal openrc Stage 3->

/etc/inittab
s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt102

3 Likes

Ok I will have to wait until I find my usb to serial adapter.

Thanks this worked to get the serial adapter working on Gentoo.

I have Gentoo running now :slightly_smiling_face:

2 Likes

Some details would be appreciated.

Gentoo runs faster on my Visionfive2 than it does on my Raspberry pi 4 running Gentoo.
I compared compile times using the genlop -t command as well as simple benchmarks like
time echo “scale=5000; 4*a(1)” | bc -l

1 Like