Consider building world for riscv/riscv64 on an arm64/aarch64 host with
the following command:
make buildworld -DNO_ROOT \ DESTDIR=/home/0mp/bricoler/freebsd-src-build/stage.riscv.riscv64 \ METALOG=/home/0mp/bricoler/freebsd-src-build/stage.riscv.riscv64/METALOG.buildworld.mtree \ TARGET=riscv \ TARGET_ARCH=riscv64 \ KERNCONF=GENERIC \ WITH_REPRODUCIBLE_BUILD=yes \ WITH_CCACHE_BUILD=yes \ WITHOUT_CLEAN= \ WITHOUT_CLANG= \ WITHOUT_LLD= \ WITHOUT_LLDB= \ WITHOUT_LIB32= \ WITHOUT_ZFS_TESTS=
The build errors out during "stage 3: cross tools" when building
"lib/clang/libclang (all)":
*** Failed target: clang/AST/AbstractBasicWriter.inc
*** In directory: /home/0mp/src/lib/clang/libclang
*** Failed commands:
${CLANG_TBLGEN} -gen-clang-basic-writer -I ${CLANG_SRCS}/include -d ${.TARGET:C/$/.d/} -o ${.TARGET} ${CLANG_SRCS}/include/clang/AST/PropertiesBase.td
=> clang-tblgen -gen-clang-basic-writer -I /home/0mp/src/contrib/llvm-project/clang/include -d clang/AST/AbstractBasicWriter.inc.d -o clang/AST/AbstractBasicWriter.inc /home/0mp/src/contrib/llvm-project/clang/include/clang/AST/PropertiesBase.td
*** [clang/AST/AbstractBasicWriter.inc] Error code 127It seems that clang-tblgen is not available to lib/clang/libclang.
In fact, clang-tblgen is nowhere to be found in the build artifacts.
find ~/bricoler -name '*clang-tblgen* returns nothing.
An immediate workaround is to build without WITHOUT_CLANG.
However, there must be a better way.
It turns out that
clang_tblgen+= usr.bin/clang/clang-tblgen
gets added to the bootstrap-tools target during the cross-tools target
pass of Makefile.inc1 (thanks to MK_CLANG=yes). This is sadly too late.
What would help is to plug clang-tblgen to bootstrap-tools when
${MK_LLVM_BINUTILS_BOOTSTRAP} != "no" || ${MK_LLVM_BINUTILS} != "no"but I'm not sure if that's correct.
Let's consider the if statements surrounding _clang_libs:
.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_LLD_BOOTSTRAP} != "no" || \
${MK_LLVM_BINUTILS_BOOTSTRAP} != "no"
_clang_libs= lib/clang
.endifPerhaps adding
${MK_LLVM_BINUTILS_BOOTSTRAP} != "no"to clang-tblgen if statement is not wrong:
.if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
${MK_LLDB} != "no" || ${MK_LLVM_BINUTILS_BOOTSTRAP} != "no"
_clang_tblgen+= lib/clang/libclangminimal
_clang_tblgen+= usr.bin/clang/clang-tblgen
.endifSponsored by: fme AG