On recent CURRENT (FreeBSD 12.0-CURRENT #106 r333789: Fri May 18 14:48:40 CEST 2018 amd64) building port emulators/virtualbox-ose-kmod (ports tree revision at 470673), via PORTS+MODULES= in /etc/src.conf as part of the kernel, fails with the error shown below:
=== Building 'vboxnetflt' module ===
machine -> /usr/src/sys/amd64/include
x86 -> /usr/src/sys/x86/include
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/device_if.m -h
awk -f /usr/src/sys/tools/makeobjops.awk /usr/src/sys/kern/bus_if.m -h
Warning: Object directory not changed from original /usr/obj/usr/src/amd64.amd64/sys/GLOCKE/usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-5.2.12/out/freebsd.amd64/release/bin/src/vboxnetflt
cc -O2 -pipe -march=native -fno-strict-aliasing -DRT_OS_FREEBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -w -DVBOX_WITH_HARDENING -DVIMAGE -DRT_ARCH_AMD64 -march=native -Werror -D_KERNEL -DKLD_MODULE -nostdinc -Iinclude -I. -Ir0drv -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -MD -MF.depend.VBoxNetFlt-freebsd.o -MTVBoxNetFlt-freebsd.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wcast-qual -Wundef -Wno-pointer-sign -D__printf__=__freebsd_kprintf__ -Wmissing-include-dirs -fdiagnostics-show-option -Wno-unknown-pragmas -Wno-error-tautological-compare -Wno-error-empty-body -Wno-error-parentheses-equality -Wno-error-unused-function -Wno-error-pointer-sign -Wno-error-shift-negative-value -Wno-address-of-packed-member -mno-aes -mno-avx -std=iso9899:1999 -c VBoxNetFlt-freebsd.c -o VBoxNetFlt-freebsd.o
In file included from VBoxNetFlt-freebsd.c:63:
In file included from include/VBox/err.h:30:
In file included from include/iprt/err.h:30:
include/iprt/types.h:73:5: error: "offsetof is not defined!"
# error "offsetof is not defined!"
1 error generated.
*** Error code 1
make: stopped in /usr/obj/usr/src/amd64.amd64/sys/GLOCKE/usr/ports/emulators/virtualbox-ose-kmod/work/VirtualBox-5.2.12/out/freebsd.amd64/release/bin/src/vboxnetflt
*** Error code 1
Created attachment 193639 [details]
I've hit this myself just now.
Having a look at the failing part of the source code it looks like what they define as a kludge is not necessary anymore and has been fixed in base r324622.
I also suspect the kludge was already not necessary when they switched from including stddef.h to including sys/stddef.h, which has never diverged from types.h in the definition of offsetof.
I've made a very simple patch removing the kludge and simply including the required files. It does compile, but I still have to test it at runtime, which I will do once building a bunch of other packages is done and report back.
I'm anyway attaching my patch for reference.
(In reply to Guido Falsi from comment #1)
> Created attachment 193639 [details]
> Tantive patch
> I'm anyway attaching my patch for reference.
With the attached patch it compiles and works fine on head r334087.
I'll update the patch to limit it's scope based on __FreeBSD_version, but I still have to identify the correct values for that.
A commit references this bug:
Date: Fri Jun 1 00:30:51 UTC 2018
New revision: 471248
Remove obsolete kludges. All supported versions do not need these hacks.
Furthermore, these hacks break build on head.
(In reply to Guido Falsi from comment #2)
All supported versions do not need the kludges. Confirmed with Poudriere.
(In reply to Jung-uk Kim from comment #5)
> (In reply to Guido Falsi from comment #2)
> All supported versions do not need the kludges. Confirmed with Poudriere.
Thanks for checking this and taking care of it!