Brett Glass
2009-Nov-26 18:10 UTC
8.0 kernel fails to build if some USB drivers are trimmed out; error in /sys/conf/files
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.
Jeremy Chadwick
2009-Nov-26 18:44 UTC
8.0 kernel fails to build if some USB drivers are trimmed out; error in /sys/conf/files
On Thu, Nov 26, 2009 at 10:43:13AM -0700, Brett Glass wrote:> 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.Missing symbols are almost always the sign of a missing "device" directive inside of the kernel configuration file. In this case, they're part of sys/dev/usb/net/usb_ethernet.[ch], which should be being built. You absolutely need to include the following devices in addition to "device udav": device ether device miibus I assume you did leave "device usb" and related pieces (meaning lines around that area) intact. Keeping it simple: can we see your kernel configuration file in its entirety? It isn't included in the PR, nor in this Email.> More experimentation seems to indicate that the GENERIC kernel builds by sheer > luck, due to an odd quirk in the "config" utility.I haven't used "config" since the early 3.x days. I'm certain "make buildkernel" and friends relies on it, but configuring a kernel + building a kernel is a lot simpler now. Read /usr/src/Makefile, starting with the line "For individuals wanting to upgrade their sources". The steps there are accurate. I don't think parenthesis are the core of the problem, given that there are many other devices in /sys/conf/files which utilise said method. -- | Jeremy Chadwick jdc@parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP: 4BD6C0CB |