Re: Problem with cc in native build

From: Michael Tuexen <tuexen_at_FreeBSD.org>
Date: Sat, 14 Jun 2025 10:50:11 UTC
> On 14. Jun 2025, at 11:29, Milan Obuch <freebsd-riscv@dino.sk> wrote:
> 
> 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...
I am building FreeBSD on a RiscV board (HiFive Unmatched Rev B). The last
time a month ago or so.
I get
tuexen@riscv:~ % cc -print-target-triple
riscv64-unknown-freebsd15.0
tuexen@riscv:~ % cc -print-targets

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    ppc32      - PowerPC 32
    ppc32le    - PowerPC 32 LE
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64

Let me trigger a new build.

Best regards
Michael
> 
> Regards,
> Milan
>