1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Compiling kernel module out of tree

Discussion in 'FreeBSD Development' started by Need4Speed, Nov 24, 2011.

  1. Need4Speed

    Need4Speed New Member

    Thanks Received:

    With FreeBSD 8.1 I was able to build a kernel module in my home directory with a Makefile and the C source file. The Makefile contains:

    .PATH: ${.CURDIR}
    KMOD=	uslcom
    SRCS=	opt_bus.h opt_usb.h device_if.h bus_if.h usb_if.h usbdevs.h uslcom.c
    .include <bsd.kmod.mk>

    Now, with FreeBSD 8.2, I get this:

    "/sys/conf/kmod.mk", line 199: warning: duplicate script for target "uslcom" ignored
    "/sys/conf/kmod.mk", line 203: warning: duplicate script for target "uslcom" ignored
    "/sys/conf/kmod.mk", line 210: warning: duplicate script for target "uslcom" ignored
    Warning: Object directory not changed from original /usr/home/jdl/projects/cp210x
    Graph cycles through uslcom
    @ -> /usr/src/sys
    machine -> /usr/src/sys/i386/include
    :> opt_bus.h
    :> opt_usb.h
    awk -f @/tools/makeobjops.awk @/kern/device_if.m -h
    awk -f @/tools/makeobjops.awk @/kern/bus_if.m -h
    awk -f @/tools/makeobjops.awk @/dev/usb/usb_if.m -h
    awk -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -h
    cc -O2 -pipe -fno-strict-aliasing -Werror -D_KERNEL -DKLD_MODULE -nostdinc   -I. -I@ -I@/contrib/altq -finline-limit=8000 --param inline-unit-growth=100 --param large-function-growth=1000 -fno-common  -mno-align-long-strings -mpreferred-stack-boundary=2  -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -ffreestanding -fstack-protector -std=iso9899:1999 -fstack-protector -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual  -Wundef -Wno-pointer-sign -fformat-extensions -c uslcom.c
    ld  -d -warn-common -r -d -o .kld uslcom.o
    :> export_syms
    awk -f /sys/conf/kmod_syms.awk .kld  export_syms | xargs -J% objcopy % .kld
    .kldBshareable  -d -warn-common -o .ko uslcom
    .kld: No such file: No such file or directory
    *** Error code 1

    In addition to the new "duplicate script" warnings, the linker seems to want to output an empty filename (.kld instead of uslcom.kld)

    Is it still possible to compile a kernel module out of tree?