I realize I'm doing something many will say is not supported, pointless and a terrible idea, but I seem to be learning a lot about how the FreeBSD kernel works from doing this. Long story short, I'm trying build the FreeBSD kernel inside Debian. I found some documentation on how to do this here. This is what I'm using to build at the moment from inside the folder of the FreeBSD source code:
It seemed straight forward at first, but I eventually started getting errors like this:
I have this file at /home/user/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h. I linked the full path for a couple and then did some regex from the /home/user/freebsd/ directory to see how many more of these there were. My count showed a little over 340k files, so I knew this was not the best way to do this. I first tried linking the /home/user/freebsd/contrib/llvm-project/llvm/include/ directory with -I in the $CFLAGS environment variable. I was already passing other values to the kernel build this way, but it wasn't working. I did some thinking and reasoned that I'm calling ./tools/build/make.py, which is from FreeBSD. Maybe it can't see or use all the flags from the Debian environment variable. So I tried passing it directly to the make like this:
That doesn't seem to work either. Maybe I'm too used to Linux and this is something that is called differently with FreeBSD? Or maybe this is something that is just problematic when trying to build a FreeBSD kernel on non-FreeBSD hosts? I realize this is an out-of-the-box and often unpopular topic. Any advice appreciated.
MAKEOBJDIRPREFIX=/tmp/obj ./tools/build/make.py -j 8 TARGET=amd64 TARGET_ARCH=amd64 --cross-bindir=/usr/bin buildworld -DNO_ARPA_INSTALL DEBUG_FLAGS=-v
It seemed straight forward at first, but I eventually started getting errors like this:
--- Support/APFloat.o ---
In file included from /home/user/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/APFloat.h:20,
from /home/user/freebsd/contrib/llvm-project/llvm/lib/Support/APFloat.cpp:14:
/home/user/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/FloatingPointMode.h:18:10: fatal error: llvm/ADT/BitmaskEnum.h: No such file or directory
18 | #include "llvm/ADT/BitmaskEnum.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [Support/APFloat.o] Error code 1
I have this file at /home/user/freebsd/contrib/llvm-project/llvm/include/llvm/ADT/BitmaskEnum.h. I linked the full path for a couple and then did some regex from the /home/user/freebsd/ directory to see how many more of these there were. My count showed a little over 340k files, so I knew this was not the best way to do this. I first tried linking the /home/user/freebsd/contrib/llvm-project/llvm/include/ directory with -I in the $CFLAGS environment variable. I was already passing other values to the kernel build this way, but it wasn't working. I did some thinking and reasoned that I'm calling ./tools/build/make.py, which is from FreeBSD. Maybe it can't see or use all the flags from the Debian environment variable. So I tried passing it directly to the make like this:
MAKEOBJDIRPREFIX=/tmp/obj ./tools/build/make.py -I/home/user/freebsd/contrib/llvm-project/llvm/include/ -j 8 TARGET=amd64 TARGET_ARCH=amd64 --cross-bindir=/usr/bin buildworld -DNO_ARPA_INSTALL DEBUG_FLAGS=-v
That doesn't seem to work either. Maybe I'm too used to Linux and this is something that is called differently with FreeBSD? Or maybe this is something that is just problematic when trying to build a FreeBSD kernel on non-FreeBSD hosts? I realize this is an out-of-the-box and often unpopular topic. Any advice appreciated.