Unable to build kernel module

I’m trying to build a module from source code with dkms. I have managed to setup the dkms but when I build it i get the following error:

Building module:
cleaning build area…
make -j12 KERNELRELEASE=5.5.2-903.native -C /lib/modules/5.5.2-903.native/build SUBDIRS=/var/lib/dkms///build modules…(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.5.2-903.native (x86_64)
Consult /var/lib/dkms/ttyPos/1.0/build/make.log for more information.

When I consult the make.log I get the following errors:

make: Entering directory ‘/usr/lib/modules/5.5.2-903.native/build’
make[2]: *** No rule to make target ‘scripts/basic/fixdep.c’, needed by ‘scripts/basic/fixdep’. Stop.
make[1]: *** [Makefile:501: scripts_basic] Error 2
make: *** [Makefile:678: include/config/auto.conf.cmd] Error 2
make: Leaving directory ‘/usr/lib/modules/5.5.2-903.native/build’

I have downloaded the required bundles (linux-dev and kernel-native-dkms) but still cannot figure out what is happening.

Can someone give me a hand on this?
Thank you.

It looks like an issue in the project’s Makefile or maybe the make command that dkms.conf is invoking needs to be tweaked.

Can you share a link to what you’re tying to install?

I cannot share the source files, they are not public, however I can share the Makefile and dkms.conf.
Also, I can give you the project structure, if it helps, which is:

  • dkms.conf
  • Makefile
  • ttyPos.c
  • ttyPos.h
  • ttyTest.c

Imagine that this module gives access to a specific vendor devices in order to communicate with them (debug, etc)


KERNEL_VER:=(shell uname -r) KERNEL_DIR:=/lib/modules/(KERNEL_VER)/build

obj-m := ttyPos.o

(MAKE) modules -C (KERNEL_DIR) SUBDIRS=$(shell pwd)

(RM) *.o *.ko *.mod.* .*.cmd *~ (RM) -r .tmp_versions
(RM) *.order *.symvers install: all install -D -m 644 ttyPos.ko (INSTALL_DIR)/ttyPos.ko
/sbin/depmod -a
modprobe -r ttyPos ; echo -n
(RM) (INSTALL_DIR)/ttyPos.ko
/sbin/depmod -a


MAKE=“make -C {kernel_source_dir} SUBDIRS={dkms_tree}/{PACKAGE_NAME}/{PACKAGE_VERSION}/build modules”
CLEAN=“make -C {kernel_source_dir} SUBDIRS={dkms_tree}/{PACKAGE_NAME}/{PACKAGE_VERSION}/build clean”

Is this exactly what it said? Looks like maybe it’s missing PACKAGE_NAME and PACKAGE_VERSION in the /var/lib/dkms/.../build path somehow.

Or are you getting this in make.log?

as: unrecognized option '-mbranches-within-no-boundaries'

(see https://github.com/clearlinux/distribution/issues/1725)

The above error is the exact I get. /var/lib/dkms/…/build contains the dkms.conf which includes both PACKAGE_NAME & PACKAGE_VERSION.

Also, I’m not getting

as: unrecognized option ‘-mbranches-within-no-boundaries’

anywhere in the make.log.

Can you try taking the MAKE and CLEAN lines out of dkms.conf? The defaults should work fine, and I suspect the variables just aren’t being substituted properly. Also, $ is missing in a lot of your pastes.

Yeah, that fixed the error but know I get the:

as: unrecognized option ‘-mbranches-within-no-boundaries’

I saw, the workaround is to move to lts channel or build my own kernel, is that right?

As written in the nvidia driver thread
Im affected by it too. I dont think that it is totally related to Nvidia. My guess is that some flags are passed through to dkms.
I was not able to find anything about the flag “-mbranches-within-no-boundaries”
What I have found “-mbranches-within-32B-boundaries” AFAIK this is needed to mitigate the Jump Conditional Code Issue. https://www.phoronix.com/scan.php?page=article&item=intel-jcc-microcode&num=1

But “-mno-branches-within-32B-boundaries” does exist …maybe it is just some typo?

edit: it does exist https://github.com/clearlinux-pkgs/binutils/blob/f5fa47ed3a295ec067e27c8981c88aa8cbdc8166/0004-i386-Add-mbranches-within-32B-boundaries.patch

@Tasos_Tsatsanis & @CochainComplex: I guess you already have read https://docs.01.org/clearlinux/latest/guides/kernel/kernel-modules-dkms.html


After several retries I managed to build the module. Don’t know how, for real.

@CochainComplex It doesn’t seem that binutils nor -mno-branches-within-32B-boundaries was my (actual) problem, however, I got into them, but afterwards they disappeared. And If you ask me, no changes where made, just deleted dirs, copied files again and re-build them (as [https://docs.01.org/clearlinux/latest/guides/kernel/kernel-modules-dkms.html ] says).

According to @miguelinux - “mbranches-within-no-boundaries” is fixed upstream https://github.com/clearlinux/distribution/issues/1741