# Cannot build kernel from sources on FreeBSD 13 amd64



## lucic71 (Oct 17, 2021)

Hello,

I have an Ubuntu machine running 5.3.0-40-generic on amd64, on top of it i run virt-manager (https://virt-manager.org/). Recently I installed, using virt-manager, a new virtual machine containing FreeBSD 13. Later I downloaded the sources from this fork and tried to compile them using the following commands:

```
make -j6 -DNO_CLEAN buildworld
make -j6 -DKERNFAST buildkernel
```

buildworld completes successfully:

```
--------------------------------------------------------------
>>> World build completed on Sun Oct 17 00:34:40 EEST 2021
>>> World built in 7282 seconds, ncpu: 6, make -j6
--------------------------------------------------------------
```

Unfortunately, buildkernel throws the following error:

```
--- buildkernel ---
make[1]: "/usr/src/Makefile.inc1" line 341: SYSTEM_COMPILER: libclang will be built for bootstrapping a cross-compiler.
make[1]: "/usr/src/Makefile.inc1" line 344: SYSTEM_LINKER: Determined that LD=ld matches the source tree.  Not bootstrapping a cross-linker.
--- buildkernel ---
--------------------------------------------------------------
>>> Kernel build for GENERIC started on Sun Oct 17 11:11:46 EEST 2021
--------------------------------------------------------------
===> GENERIC
mkdir -p /usr/obj/usr/src/amd64.amd64/sys
cd /usr/src; MACHINE_ARCH=amd64  MACHINE=amd64  CPUTYPE= CC="cc -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin" CXX="c++  -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin"  CPP="cpp -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin"  AS="as" AR="ar" LD="ld" LLVM_LINK=""  NM=nm OBJCOPY="objcopy"  RANLIB=ranlib STRINGS=  SIZE="size" STRIPBIN="strip"  INSTALL="install -U"  PATH=/usr/obj/usr/src/amd64.amd64/tmp/bin:/usr/obj/usr/src/amd64.amd64/tmp/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/libexec::/sbin:/bin:/usr/sbin:/usr/bin  SYSROOT=/usr/obj/usr/src/amd64.amd64/tmp make  -f Makefile.inc1  BWPHASE=buildkernel  DESTDIR=/usr/obj/usr/src/amd64.amd64/tmp _cleankernobj_fast_depend_hack
--- _cleankernobj_fast_depend_hack ---
--------------------------------------------------------------
>>> stage 2.3: build tools
--------------------------------------------------------------
cd /usr/src; TOOLS_PREFIX=/usr/obj/usr/src/amd64.amd64/tmp  INSTALL="sh /usr/src/tools/install.sh"  PATH=/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/libexec:/sbin:/bin:/usr/sbin:/usr/bin  WORLDTMP=/usr/obj/usr/src/amd64.amd64/tmp  MAKEFLAGS="-m /usr/src/tools/build/mk  -j 6 -D KERNFAST -J 15,16 -m /usr/src/share/mk" make  -f Makefile.inc1  DESTDIR=  OBJTOP='/usr/obj/usr/src/amd64.amd64/tmp/obj-kernel-tools'  OBJROOT='${OBJTOP}/'  MAKEOBJDIRPREFIX=  BOOTSTRAPPING=1300139  SSP_CFLAGS=  MK_HTML=no -DNO_LINT MK_MAN=no  -DNO_PIC MK_PROFILE=no -DNO_SHARED  -DNO_CPU_CFLAGS MK_RETPOLINE=no MK_WERROR=no MK_CTF=no kernel-tools
--- kernel-tools ---
mkdir -p /usr/obj/usr/src/amd64.amd64/tmp/usr
mtree -deUW -f /usr/src/etc/mtree/BSD.usr.dist  -p /usr/obj/usr/src/amd64.amd64/tmp/usr >/dev/null
--------------------------------------------------------------
>>> stage 3.1: building everything
--------------------------------------------------------------
cd /usr/obj/usr/src/amd64.amd64/sys/GENERIC; MACHINE_ARCH=amd64 MACHINE=amd64 CPUTYPE= CC="cc -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin" CXX="c++  -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin" CPP="cpp -target x86_64-unknown-freebsd14.0 --sysroot=/usr/obj/usr/src/amd64.amd64/tmp -B/usr/obj/usr/src/amd64.amd64/tmp/usr/bin" AS="as" AR="ar" LD="ld" LLVM_LINK="" NM=nm OBJCOPY="objcopy" RANLIB=ranlib STRINGS= SIZE="size" STRIPBIN="strip" INSTALL="install -U" PATH=/usr/obj/usr/src/amd64.amd64/tmp/bin:/usr/obj/usr/src/amd64.amd64/tmp/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/sbin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/bin:/usr/obj/usr/src/amd64.amd64/tmp/legacy/usr/libexec::/sbin:/bin:/usr/sbin:/usr/bin make  -j 6 -D KERNFAST -J 15,16 -m /usr/src/share/mk  KERNEL=kernel all -DNO_MODULES_OBJ
cd: /usr/obj/usr/src/amd64.amd64/sys/GENERIC: No such file or directory

make[1]: stopped in /usr/src

make: stopped in /usr/src
```

I don't understand why it doesn't create a GENERIC directory in /usr/obj/usr/src/amd64.amd64/sys, I guess it should be created in buildworld.

Thank you,
Lucian Popescu


----------



## SirDice (Oct 17, 2021)

lucic71 said:


> Later I downloaded the sources from this fork


Ask the maintainers of that fork why it doesn't build. We can't support every fork anyone ever makes. We do support building the actual FreeBSD sources. You can get those from here: https://cgit.freebsd.org/src/ or here: https://github.com/freebsd/freebsd-src

24.5. Updating FreeBSD from Source


----------



## grahamperrin@ (Oct 17, 2021)

lucic71 said:


> this fork



What's signified by _UPB_?


----------



## lucic71 (Oct 18, 2021)

The problem was that I used DKERNFAST without realizing it was the first time running make buildkernel.


----------

