I have very little experience with kernel module development. Despite this I have been tasked with maintaining an old driver for a Sensoray 626 DAQ card. I am using a very simple dkms setup to build and install the driver which has been working well for a long time. The driver has been working in Ubuntu 22.04 until recently I ran into the error below during the kernel module build and I'm unable to find a solution. Any help is appreciated. If additional information is needed, simply ask and I will update the question with the requested information.
Note: I am aware that Comedi has a driver for the Sensoray 626. I do not want to use the Comedi driver.
DKMS build log:
DKMS make.log for s626-1.0.5 for kernel 6.5.0-14-generic (x86_64)Fri Jan 12 01:17:52 PM PST 2024make -C /lib/modules/6.5.0-14-generic/build M=/var/lib/dkms/s626/1.0.5/build SUBDIRS=/var/lib/dkms/s626/1.0.5/buildmake[1]: Entering directory '/usr/src/linux-headers-6.5.0-14-generic'warning: the compiler differs from the one used to build the kernel The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 You are using: gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0 CC [M] /var/lib/dkms/s626/1.0.5/build/s626drv.ogcc: error: unrecognized command-line option ‘-ftrivial-auto-var-init=zero’make[3]: *** [scripts/Makefile.build:251: /var/lib/dkms/s626/1.0.5/build/s626drv.o] Error 1make[2]: *** [/usr/src/linux-headers-6.5.0-14-generic/Makefile:2037: /var/lib/dkms/s626/1.0.5/build] Error 2make[1]: *** [Makefile:234: __sub-make] Error 2make[1]: Leaving directory '/usr/src/linux-headers-6.5.0-14-generic'make: *** [Makefile:29: all] Error 2
- Distribution: Ubuntu 22.04.3 LTS
- Linux kernel version: 6.5.0-14-generic
Output of apt list --installed | grep gcc
gcc-11-base/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]gcc-11/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]gcc-12-base/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]gcc-12/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]gcc/jammy,now 4:11.2.0-1ubuntu1 amd64 [installed,automatic]libgcc-11-dev/jammy-updates,jammy-security,now 11.4.0-1ubuntu1~22.04 amd64 [installed,automatic]libgcc-12-dev/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]libgcc-s1/jammy-updates,jammy-security,now 12.3.0-1ubuntu1~22.04 amd64 [installed,automatic]
Makefile (note this makefile has recipes for things other than the kernel module and the CC
variable is not used for building the kernel module):
################################################################################ for kernel modeule level driver:# Kernel directoryKDIR := /lib/modules/$(shell uname -r)/build# Module directoryMODDIR := /lib/modules/$(shell uname -r)/kernel/drivers/sensoray# System valuesPWD := $(shell pwd)KERNEL_24 := $(if $(wildcard $(KDIR)/Rules.make),1,0)# Target fileobj-m := s626.o# Source filesifeq ($(KERNEL_24),0) # > 2.4s626-objs := s626drv.o else # <= 2.4s626-objs := s626drv.oendif.PHONY: all clean modules_installifeq ($(KERNEL_24),0) # > 2.4ifeq ($(KERNELRELEASE),)all: $(MAKE) -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD)clean modules_install: $(MAKE) -C $(KDIR) M=$(PWD) SUBDIRS=$(PWD) $@endif # KERNELRELEASEelse # <= 2.4ifneq ($(KERNELRELEASE),)include $(KDIR)/Rules.makes626.o: $(s626-objs) $(Q)$(LD) $(LD_RFLAG) -r -o $@ $(s626-objs)elseall: $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modulesclean: rm -f *.ko *.o .*.cmd .*.o.flags *.mod.cendif # KERNELRELEASEendif # KERNEL_24ifeq ($(KERNEL_24),1) # <= 2.4install: s626.o @if [ -d /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/ ];\ then rm -f /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/s626.*;\ fi @if [ -d /lib/modules/$(shell uname -r)/extra/ ];\ then rm -f /lib/modules/$(shell uname -r)/extra/s626.*;\ fi su -c "set -x;./MAKEDEV;mkdir -p $(MODDIR);cp -v s626.o $(MODDIR);depmod -a"elseinstall: s626.ko @if [ -d /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/ ];\ then rm -f /lib/modules/$(shell uname -r)/kernel/drivers/sensoray/s626.*; \ fi @if [ -d /lib/modules/$(shell uname -r)/extra/ ];\ then rm -f /lib/modules/$(shell uname -r)/extra/s626.*;\ fi @if [ -d /lib/modules/$(shell uname -r)/kernel/drivers/staging/comedi/drivers ];\ then rm -f /lib/modules/$(shell uname -r)/kernel/drivers/staging/comedi/drivers/s626.*;\ fi su -c "set -x;./MAKEDEV;mkdir -p $(MODDIR);cp -v s626.ko $(MODDIR);install -m 444 s626.ko $(MODDIR);depmod -a"endif # KERNEL > 2.4################################################################################ for library and application level:SRC= # module source treeCC= # compilerAR= # library manager# source pathifeq ($(strip $(SRC)),) SRC=.endif# the compilerifeq ($(strip $(CC)),) CC=gccendif# the library managerifeq ($(strip $(AR)),) AR=arendif# build the distribution's librarylib: libs626.alibs626.a: s626core.o s626mod.o $(AR) cr libs626.a $(SRC)/s626core.o $(SRC)/s626mod.o# compile the 626 universal corecore: s626core.os626core.o: $(SRC)/s626core.c $(SRC)/s626core.h $(SRC)/s626mod.h $(CC) $(CFLAGS) -c $(SRC)/s626core.c# build the 626 OS-dependent modulemod: s626mod.os626mod.o: $(SRC)/s626mod.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626.h $(SRC)/s626api.h $(CC) $(CFLAGS) -c $(SRC)/s626mod.c# build the distribution's library (you may need to install gcc-multilib package)lib32: libs626-32.alibs626-32.a: s626core-32.o s626mod-32.o $(AR) cr libs626-32.a $(SRC)/s626core-32.o $(SRC)/s626mod-32.o# compile the 626 universal cores626core-32.o: $(SRC)/s626core.c $(SRC)/s626core.h $(SRC)/s626mod.h $(CC) $(CFLAGS) -m32 -c $(SRC)/s626core.c -o $@# build the 626 OS-dependent modules626mod-32.o: $(SRC)/s626mod.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626.h $(SRC)/s626api.h $(CC) $(CFLAGS) -m32 -c $(SRC)/s626mod.c -o $@#----------------------------------------------------------------# Demonstration programs# type "make demo" to compile, link, and create demo applicationdemo: libs626.a s626demo.o s626dm2b.o $(CC) -o s626demo s626demo.o -L$(SRC) -ls626 -lpthread $(CC) -o s626dm2b s626dm2b.o -L$(SRC) -ls626 -lpthreads626demo.o: $(SRC)/s626demo.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h $(CC) $(CFLAGS) -c $(SRC)/s626demo.cs626dm2b.o: $(SRC)/s626dm2b.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h $(CC) $(CFLAGS) -c $(SRC)/s626dm2b.cdemo32: libs626-32.a s626demo-32.o s626dm2b-32.o $(CC) -m32 -o s626demo-32 s626demo-32.o -L$(SRC) -ls626-32 -lpthread $(CC) -m32 -o s626dm2b-32 s626dm2b-32.o -L$(SRC) -ls626-32 -lpthreads626demo-32.o: $(SRC)/s626demo.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h $(CC) $(CFLAGS) -m32 -c $(SRC)/s626demo.c -o $@s626dm2b-32.o: $(SRC)/s626dm2b.c $(SRC)/s626core.h $(SRC)/s626mod.h $(SRC)/s626drv.h $(SRC)/s626api.h $(SRC)/App626.h $(CC) $(CFLAGS) -m32 -c $(SRC)/s626dm2b.c -o $@# for debugging:# gcc -g -o s626demo s626core.c s626mod.c s626demo.c -lpthread# gcc -g -o s626dm2b s626core.c s626mod.c s626dm2b.c -lpthreadclnall: rm -f *.ko *.o .*.cmd .*.o.flags *.mod.c libs626*.a s626demo s626dm2b *.tar.gz s626*-32 Module.symvers modules.order################################################################################ for internal develoment only#----------------------------------------------------------------# select files for the distribution tarballT = $(SRC)/READMET += $(SRC)/COPYINGT += $(SRC)/MAKEDEVT += $(SRC)/Modules.confT += $(SRC)/MakefileT += $(SRC)/s626drv.hT += $(SRC)/s626drv.cT += $(SRC)/s626.hT += $(SRC)/s626mod.hT += $(SRC)/s626mod.cT += $(SRC)/s626core.hT += $(SRC)/s626core.cT += $(SRC)/s626api.hT += $(SRC)/App626.hT += $(SRC)/libs626.aT += $(SRC)/s626demo.cT += $(SRC)/s626dm2b.c#----------------------------------------------------------------# build distribution tarball (only for development)tar:# tar -Pzcf s626-0.3.tar.gz $(T) tar -czvf s626-1.0.tar.gz $(T)
DKMS configuration file:
MAKE="'make' KDIR=/lib/modules/${kernelver}/build"CLEAN="'make' clean"BUILT_MODULE_NAME=s626BUILT_MODULE_LOCATION=./DEST_MODULE_LOCATION=/kernel/drivers/sensoray/PACKAGE_NAME=s626PACKAGE_VERSION=1.0.5AUTOINSTALL=yesREMAKE_INITRD=yes