Problem with cc in native build

From: Milan Obuch <freebsd-riscv_at_dino.sk>
Date: Sat, 14 Jun 2025 09:29:31 UTC
Hi,

I did native build on Star64, but there is something wrong with cc
binary generated.

I started with sme snapshot from ftp.freebsd.org, then I did all the
usual steps (make buildworld, make buildkernel, make installkernel,
make installworld), as I do on other systems when doing full source
based upgrade.

That seemingly went OK, I can boot newly boot system and check devices,
interfaces,files, etc. Now, I tried another buildkernel to test some
changes, but that failed. The error was (at stage 3.1: building
everything, on first cc invocation)

cc -target riscv64-unknown-freebsd15.0 --sysroot=/usr/obj/usr/src/riscv.riscv64/tmp -B/usr/obj/usr/src/riscv.riscv64/tmp/usr/bin -c -O2 -pipe -fno-strict-aliasing -g -nostdinc -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -I/usr/src/sys/contrib/libfdt -I/usr/src/sys/contrib/device-tree/include -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h -fPIE -fno-omit-frame-pointer -fno-optimize-sibling-calls -MD -MF.depend.genoffset.o -MTgenoffset.o -fdebug-prefix-map=./machine=/usr/src/sys/riscv/include -march=rv64imafdch -mabi=lp64 -mno-relax -ffreestanding -fwrapv -fstack-protector -gdwarf-4 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wswitch -Wno-error=tautological-compare -Wno-error=empty-body -Wno-error=parentheses-equality -Wno-error=unused-function -Wno-error=pointer-sign -Wno-error=shift-negative-value -Wno-
 address-of-packed-member -Wno-format-zero-length -mcmodel=medium -std=gnu17  -fcommon /usr/src/sys/kern/genoffset.c
error: unable to create target: 'No available targets are compatible with triple "riscv64-unknown-freebsd15.0"'
1 error generated.
*** Error code 1

I do not understand the issue, but trying

# cc -print-target-triple
riscv64-unknown-freebsd15.0

looks OK, however

# cc -print-targets

  Registered Targets:
    arm     - ARM
    armeb   - ARM (big endian)
    thumb   - Thumb
    thumbeb - Thumb (big endian)

probably means cc as built cannot actually compile for riscv arch...

Did anybody tried building FreeBSD natively on some RiscV platform? I
think this is some kind of oversight in build process, but really fatal
one...

Regards,
Milan