Building the kernel on MacOS

From: Kajetan Staszkiewicz <vegeta_at_tuxpowered.net>
Date: Wed, 10 May 2023 11:44:12 UTC
Hello Group,

I'm trying to build the FreeBSD kernel on my MacOS laptop. Following the 
documentation at https://wiki.freebsd.org/BuildingOnNonFreeBSD and in 
src/.github/workflows/cross-bootstrap-tools.yml I'm lead to believe that

MAKEOBJDIRPREFIX=~/InnoGames/projects/freebsd-makeobjkdir-14 \
tools/build/make.py \
--host-bindir /opt/homebrew/Cellar/llvm/16.0.3/bin \
--host-compiler-type=clang \
TARGET=arm64 TARGET_ARCH=aarch64 kernel-toolchain

is the right step towards getting the proper environment. Also I 
understand that using bmake from brew should work too.

Unfortunately this command fails due to the build procedure including 
MacOS headers:

--- _bootstrap-tools-sbin/md5 ---
/Users/vegeta/InnoGames/projects/freebsd-src/sbin/md5/md5.c:606:9: 
error: use of undeclared identifier 'errno'
                                 if (errno != ENOENT || !(cflag && 
ignoreMissing)) {
                                     ^
/Users/vegeta/InnoGames/projects/freebsd-src/sbin/md5/md5.c:606:18: 
error: use of undeclared identifier 'ENOENT'
                                 if (errno != ENOENT || !(cflag && 
ignoreMissing)) {
                                              ^
--- _bootstrap-tools-lib/libelf ---
[Creating objdir 
/Users/vegeta/InnoGames/projects/freebsd-makeobjkdir-14/Users/vegeta/InnoGames/projects/freebsd-src/arm64.aarch64/tmp/obj-tools/lib/libelf...]
--- _bootstrap-tools-sbin/md5 ---
/Users/vegeta/InnoGames/projects/freebsd-src/sbin/md5/md5.c:1033:7: 
error: use of undeclared identifier '__FreeBSD_version'
             (__FreeBSD_version / 1000) % 100);
              ^
/Users/vegeta/InnoGames/projects/freebsd-src/sbin/md5/md5.c:1032:6: 
error: use of undeclared identifier '__FreeBSD_version'
             __FreeBSD_version / 100000,


The error I'm getting is the same as in FreeBSD GitHub builds, e.g. 
https://github.com/freebsd/freebsd-src/actions/runs/4932067780/jobs/8814737228#step:7:1317 
. The GitHub builds seem to be failing for a few days.

Adding --bootstrap-toolchain does not solve the issue.

-- 
| pozdrawiam / greetings | Powered by macOS, Debian and FreeBSD |
|  Kajetan Staszkiewicz  |  www: http://vegeta.tuxpowered.net   |
`------------------------^--------------------------------------'