Re: Problem with cc in native build

From: Dennis Clarke <dclarke_at_blastwave.org>
Date: Sat, 14 Jun 2025 11:29:58 UTC
On 6/14/25 07:08, Milan Obuch wrote:
> On Sat, 14 Jun 2025 12:50:11 +0200
> Michael Tuexen <tuexen@FreeBSD.org> wrote:
> 
>>> 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.
>>
> 
> Great. I did use sources from June 1st, git hash 66c2e68076bd.
> 
> But I just found the issue... My /etc/src.conf is the culprit

What do you have in /etc/src.conf ?

Here I have disabled a pile of things I will never use or want on a 
SiFive UnMatched Rev B board :

enceladus$ cat /etc/src.conf
WITH_CCACHE_BUILD=yes
CCACHE_DIR=/var/cache/ccache/

WITH_REPRODUCIBLE_BUILD=yes

WITHOUT_AMD=yes
WITHOUT_ATM=yes
WITHOUT_AUDIT=yes
WITHOUT_AUTOFS=yes
WITHOUT_BLUETOOTH=yes
WITHOUT_BOOTPARAMD=yes
WITHOUT_BOOTPD=yes
WITHOUT_BSNMP=yes
WITHOUT_CALENDAR=yes
WITHOUT_CCD=yes
WITHOUT_CTF=yes
WITHOUT_CXGBETOOL=yes
WITHOUT_DIALOG=yes
WITHOUT_DICT=yes
WITHOUT_DTRACE_TESTS=yes
WITHOUT_DTRACE=yes
WITHOUT_EE=yes
WITHOUT_EXAMPLES=yes
WITHOUT_FINGER=yes
WITHOUT_FLOPPY=yes
WITHOUT_FREEBSD_UPDATE=yes
WITHOUT_FTP=yes
WITHOUT_GAMES=yes
WITHOUT_GCOV=yes
WITHOUT_GNU_DIFF=yes
WITHOUT_GOOGLETEST=yes
WITHOUT_HTML=yes
WITHOUT_HYPERV=yes
WITHOUT_IPFILTER=yes
WITHOUT_IPFW=yes
WITHOUT_KERBEROS_SUPPORT=yes
WITHOUT_KERBEROS=yes
WITHOUT_LIB32=yes
WITHOUT_LPR=yes
WITHOUT_MAN_UTILS=yes
WITHOUT_NDIS=yes
WITHOUT_NIS=yes
WITHOUT_PMC=yes
WITHOUT_PORTSNAP=yes
WITHOUT_PPP=yes
WITHOUT_PROFILE=yes
WITHOUT_QUOTAS=yes
WITHOUT_RBOOTD=yes
WITHOUT_ROUTED=yes
WITHOUT_SHAREDOCS=yes
WITHOUT_SVNLITE=yes
WITHOUT_TALK=yes
WITHOUT_TELNET=yes
WITHOUT_TESTS=yes
WITHOUT_TFTP=yes
WITHOUT_WIRELESS_SUPPORT=yes
WITHOUT_WIRELESS=yes
enceladus$

The only other change is that sys/riscv/conf/GENERIC has the line :

     options         COMPAT_FREEBSD11        # Compatible with FreeBSD11

Strictly for the situation with lang/rust which will likely never get fixed.

So I am curious what you have in your /etc/src.conf file.


-- 
--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken