FBSD: Set KERNBUILDDIR for --with-bsd-kernel-build 46/13746/4
authorAndrew Deason <adeason@dson.org>
Sun, 28 Jul 2019 20:03:43 +0000 (15:03 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Sun, 25 Aug 2019 23:50:22 +0000 (19:50 -0400)
Currently, specifying --with-bsd-kernel-build during configure causes
us to set BSD_KERNEL_BUILD, which sets KBLD in MakefileProto.FBSD.in,
but nothing ever uses KBLD. This means that when we use
--with-bsd-kernel-build, we don't actually build against the
configuration for that kernel, which can result in a libafs.ko that
cannot be loaded or causes other errors. Specifically, if trying to
build for a VIMAGE kernel, the kernel complains when trying to load
libafs:

    [...] kernel: link_elf_obj: symbol in_ifaddrhead undefined
    [...] kernel: linker_load_file: Unsupported file type

The FreeBSD module build system looks for KERNBUILDDIR for an
alternative build, which it uses to pull in opt_global.h and other
required pieces from the build tree. So just specify KERNBUILDDIR if
we have one.

At the same time, avoid setting our default value for BSD_KERNEL_BUILD
for FBSD when the calculated dir doesn't exist. At least for the
default GENERIC kernel on FreeBSD 11.2-RELEASE, there may not be a
build dir on the running machine, and so setting BSD_KERNEL_BUILD to
the calculated value causes the build to fail when it doesn't exist.

Change-Id: Ib3079354f9f6dba13970de5308bbcecaf9b35059
Reviewed-on: https://gerrit.openafs.org/13746
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/cf/bsd.m4
src/libafs/MakefileProto.FBSD.in

index e8027d9..84dc2d7 100644 (file)
@@ -10,7 +10,8 @@ if test "x$with_bsd_kernel_build" != "x"; then
 else
     case $AFS_SYSNAME in
         *_fbsd_*)
-            BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"
+           AS_IF([test -d "${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"],
+                 [BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"])
             ;;
         *_nbsd*)
             BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/arch/${HOST_CPU}/compile/GENERIC"
index 12f24f5..26e86ea 100644 (file)
@@ -57,6 +57,9 @@ CWARNFLAGS+= -Wno-redundant-decls
 KMODDIR=/boot/modules
 KMOD=  libafs
 SYSDIR= ${KSRC}
+.if !empty(KBLD)
+KERNBUILDDIR=${KBLD}
+.endif
 
 # Name of directory to hold object files and libraries.
 KOBJ = MODLOAD