Re: Help cross-building kernel from macos

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Wed, 08 Nov 2023 21:13:59 UTC
On 11/8/23 13:54, Colin S. Gordon wrote:
> This is a longshot but: I'm trying to get cross-building working from my 
> mac so I don't have to lug 2 laptops around every day to make any 
> progress on some driver work, but so far haven't had too much luck.  
> This is (to my pleasant surprise!) supported 
> (https://docs.freebsd.org/en/books/handbook/cutting-edge/#building-on-non-freebsd-hosts <https://docs.freebsd.org/en/books/handbook/cutting-edge/#building-on-non-freebsd-hosts>) and as Ed pointed out on Mastodon, even runs successfully in CI (https://github.com/freebsd/freebsd-src/blob/main/.github/workflows/cross-bootstrap-tools.yml <https://github.com/freebsd/freebsd-src/blob/main/.github/workflows/cross-bootstrap-tools.yml>). But so far I'm unable get this working on my own machine.  I was initially trying to get this running with my slightly-stale branch where I'm doing some RISC-V stuff, but hit the same problem building a recent commit from HEAD that does cross-build from macos in CI, as evidenced here: https://github.com/freebsd/freebsd-src/actions/runs/6801518714/job/18492566834 <https://github.com/freebsd/freebsd-src/actions/runs/6801518714/job/18492566834>
> 
> I've installed the same dependencies (same version of LLVM) specified in 
> the github action file, and am building with the same commands (with 
> different local directories, of course).  I appear to be one macos 
> release ahead of the version used in CI, though it doesn't seem like 
> that should affect the failure I'm encountering.  The first command,
> 
>      MAKEOBJDIRPREFIX=~/freebsd-obj/ tools/build/make.py --debug 
> --cross-bindir=/usr/local/opt/llvm@13/bin TARGET=riscv 
> TARGET_ARCH=riscv64 -n
> 
> seems to work fine. But the second, a pre-requisite to building the 
> kernel, fails:
>
 > [... snip ...]

Just a couple of missing dependencies; this seems to do it for me [0], 
could probably still use a bit of cleanup.

diff --git a/Makefile.inc1 b/Makefile.inc1
index c1c0b56ef..d9a772a00 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2442,6 +2442,9 @@ _gensnmptree=	usr.sbin/bsnmpd/gensnmptree
  _clang_tblgen= \
  	lib/clang/libllvmminimal \
  	usr.bin/clang/llvm-tblgen
+.if ${BOOTSTRAPPING} < 1300030
+${_bt}-usr.bin/clang/llvm-tblgen: ${_bt}-lib/libzstd
+.endif
  .if ${MK_CLANG_BOOTSTRAP} != "no" || ${MK_CLANG} != "no" || \
      ${MK_LLDB} != "no"
  _clang_tblgen+=	lib/clang/libclangminimal
@@ -2475,6 +2478,7 @@ _kerberos5_bootstrap_tools= \
  	kerberos5/tools/slc \
  	usr.bin/compile_et

+${_bt}-kerberos5/lib/libroken: ${_bt}-lib/libcrypt
  .ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
  .for _tool in ${_kerberos5_bootstrap_tools}
  ${_bt}-${_tool}: ${_bt}-usr.bin/yacc ${_bt_lex_depend}

[0] https://termbin.com/oszy