Re: drm-66-kmod build fails (ttm_resource.o: undeclared identifier 'NULL')

From: Mark Johnston <markj_at_freebsd.org>
Date: Sun, 19 Jul 2026 14:12:59 UTC
On Sun, Jul 19, 2026 at 06:22:19AM -0700, David Wolfskill wrote:
> This morning's update was from:
> FreeBSD 16.0-CURRENT #637 main-n287497-506e3e30a43c: Sat Jul 18 11:04:54 UTC 2026     root@freebeast.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1600019 1600019
> 
> to;
> FreeBSD 16.0-CURRENT #638 main-n287503-cb325dcedfa2: Sun Jul 19 12:17:04 UTC 2026     root@freebeast.catwhisker.org:/common/S4/obj/usr/src/amd64.amd64/sys/GENERIC amd64 1600019 1600019
> 
> which worked OK on that headless build machine, but less so on the
> laptops.
> 
> They each use graphics/drm-66-kmod, and each reported a build failure
> for ttm_resource.o:
> 
> ...
> --- ttm_sys_manager.o ---
> 
> --- ttm_resource.o ---
> cc  -O2 -pipe -Wno-default-const-init-var-unsafe -fno-strict-aliasing  -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -include /common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/obj/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/ttm/opt_global.h -I. -I/usr/src/sys -I/usr/src/sys/contrib/ck/include -fno-common  -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fdebug-prefix-map=./machine=/usr/src/sys/amd64/include -fdebug-prefix-map=./x86=/usr/src/sys/x86/include -fdebug-prefix-map=./i386=/usr/src/sys/i386/include    -MD  -MF.depend.ttm_resource.o -MTttm_resource.o -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float  -fno-asynchronous-unwind-tables -ffreestanding -fwrapv -fstack-protector-strong  -Wall -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 -Wswitch -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 -Wno-format-zero-length -Wno-pointer-sign -Wno-default-const-init-var-unsafe -Wno-pointer-arith -Wno-format -Wno-expansion-to-defined   -mno-aes -mno-avx  -std=gnu17 -DLINUXKPI_VERSION=60600 -include /usr/src/sys/compat/linuxkpi/common/include/linux/compiler_types.h -I/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/linuxkpi/gplv2/include -I/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/linuxkpi/bsd/include -I/usr/src/sys/compat/linuxkpi/common/include -I/usr/src/sys/compat/linuxkpi/dummy/include -I/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/include -I/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/include/drm -I/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/include/uapi -I/common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/drivers/gpu '-DKBUILD_MODNAME="ttm"' '-DLINUXKPI_PARAM_PREFIX=ttm_' -DDRM_SYSCTL_PARAM_PREFIX=_ttm -DCONFIG_DRM_AMDGPU_CIK -DCONFIG_DRM_AMDGPU_SI -DCONFIG_DRM_AMD_DC -DCONFIG_DRM_AMD_DC_SI -DCONFIG_AMD_PMC -DCONFIG_DRM_EXEC -DCONFIG_DRM_I915_FORCE_PROBE='"*"' -DCONFIG_DRM_I915_REQUEST_TIMEOUT=20000 -DCONFIG_DRM_I915_CAPTURE_ERROR -DCONFIG_DRM_I915_USERFAULT_AUTOSUSPEND=250 -DCONFIG_DRM_I915_STOP_TIMEOUT=100 -DCONFIG_DRM_I915_PREEMPT_TIMEOUT=640 -DCONFIG_DRM_I915_PREEMPT_TIMEOUT_COMPUTE=7500 -DCONFIG_DRM_I915_HEARTBEAT_INTERVAL=2500 -DCONFIG_DRM_I915_TIMESLICE_DURATION=1 -DCONFIG_DRM_I915_MAX_REQUEST_BUSYWAIT=8000 -DCONFIG_DRM_I915_FENCE_TIMEOUT=10000 -DCONFIG_DRM_MIPI_DSI -DCONFIG_DRM_PANEL_ORIENTATION_QUIRKS -DCONFIG_APERTURE_HELPERS -DCONFIG_DRM_FBDEV_EMULATION -DCONFIG_DRM_FBDEV_OVERALLOC=100 -DCONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG -DCONFIG_BACKLIGHT_CLASS_DEVICE -DCONFIG_DEBUG_FS -DCONFIG_DMI -DCONFIG_FB -DCONFIG_MTRR -DCONFIG_PCI -DCONFIG_PM -DCONFIG_PM_SLEEP -DCONFIG_SMP -DCONFIG_SUSPEND -DCONFIG_VIDEO_CMDLINE -DCONFIG_ACPI -DCONFIG_ACPI_SLEEP -DCONFIG_X86 -DCONFIG_X86_PAT -DCONFIG_64BIT -DCONFIG_AS_MOVNTDQA -DCONFIG_COMPAT -DCONFIG_X86_64 -DCONFIG_DRM_AMD_DC_FP -c /common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/drivers/gpu/drm/ttm/ttm_resource.c -o ttm_resource.o
> In file included from /common/S4/obj/usr/src/amd64.amd64/sys/CANARY/common/ports/graphics/drm-66-kmod/work/drm-kmod-drm_v6.6.25_13/drivers/gpu/drm/ttm/ttm_resource.c:25:
> --- ttm_execbuf_util.o ---
> 
> --- ttm_resource.o ---
> In file included from /usr/src/sys/compat/linuxkpi/common/include/linux/iosys-map.h:6:
> In file included from /usr/src/sys/compat/linuxkpi/common/include/linux/io.h:35:
> ./machine/vm.h:64:11: error: use of undeclared identifier 'NULL'
>    64 |                 return (NULL);
>       |                         ^~~~
> 
> 
> This is with the ports tree at main-n757627-07576270db28.
> 
> There was no issue with the source tree at main-n287497-506e3e30a43c
> (when the ports tree was at main-n757619-268f8513e0b5) -- nor with the
> source tree at stable/15-n284458-299bbb762db7.
> 
> It *looks* to me as if some of the LinxKPI code took exception to
> main-n287500-a7e483ee146a:
> 
> commit a7e483ee146a93ac89357676fdb9af62ac58b4bc
> Author:     Mark Johnston <markj@FreeBSD.org>
> AuthorDate: Sun Jul 19 00:29:40 2026 +0000
> Commit:     Mark Johnston <markj@FreeBSD.org>
> CommitDate: Sun Jul 19 00:29:40 2026 +0000
> 
>     vm_phys: Add a sysctl to dump registered fictitious memory ranges
> ...
> 
> (for having the temerity to use the identifier "NULL" -- of which it was
> apparently unaware).

This should be fixed as of commit
11edc985cd9c2e1dcceccb7e929c6921b4e20c9b.