8.0 kernel fails to build if some USB drivers are trimmed out; error in /sys/conf/files

Brett Glass brett at lariat.net
Thu Nov 26 18:10:43 UTC 2009


Happy Thanksgiving to everyone in the US (and elsewhere as well)!

I encountered a strange bug when I was "trimming" the GENERIC FreeBSD
RELEASE-8.0 kernel to omit drivers for hardware that would not be used on one
target platform. I removed all of the USB Ethernet drivers except for "udav"
(Davicom USB Ethernet) and tried to rebuild the kernel. The build stopped at
the point where the kernel was linked, reporting undefined references in the
file /sys/usb/net/if_udav.c to "uether_pause", "uether_ifdetach",
"uether_getmii", and other routines with similar names. I discovered that
these functions are defined in the file usb_ethernet.c, which is in the same
directory as if_udav.c.

A look at the file /usr/src/sys/i386/compile/KERNELNAME/Makefile showed that
"usb_ethernet.o" was missing from the list of object files in the variable
"OBJS". Because the Makefile wasn't properly triggering the compilation of
usb_ethernet.c or including usb_ethernet.o in the list of files to be linked,
the build was aborting at link time due to the unresolved references.

After a bit of research (I am admittedly unfamiliar with all of the details of
the kernel build system), it appears to me that this problem is the result of
the use of parentheses on line 1623 of the file /sys/conf/files. This is the
only place in any of the kernel dependency metadata where parentheses are used
around a list of driver names, and removing them seems to solve the problem.

More experimentation seems to indicate that the GENERIC kernel builds by sheer
luck, due to an odd quirk in the "config" utility. The utility happens to do
the right thing when at least one of the drivers in the middle of the
parenthesized list (that is, not the first or last) is included in the kernel,
as is true in GENERIC. This masks the bug. But the "config" utility produces
an incorrect list of dependencies when none of the drivers in the middle of
the parenthesized list is included in the kernel.

I'll leave it to the committers to decide whether it is better to make the
"config" utility handle parentheses correctly, or simply to make sure that
no parentheses are used in the kernel dependency metadata.

I've submitted this bug as PR 140904.


More information about the freebsd-stable mailing list