Dependency issues when building an external kernel module

I'm building an out of tree kernel module for use in openwrt.

The module compiles with out errors but the build fails due to dependencies.

If i do in the module makefile:

...
 DEPENDS:=+kmod-nf-conntrack
  KCONFIG:=CONFIG_NET_SCH_ARL=y
  FILES:= \
        $(PKG_BUILD_DIR)/sch_arl.ko

  AUTOLOAD:=$(call AutoLoad,75,sch_arl)
  DEPENDS:=
endef

I'll get:

Package kmod-sched-arl is missing dependencies for the following libraries:
nf_conntrack.ko

and the build fails. I can add nf_conntract.ko (plus a couple of it's dependencies)
ala

  FILES:= \
        $(PKG_BUILD_DIR)/sch_arl.ko \
       $(LINUX_DIR)/net/netfilter/nf_conntrack.ko \
       $(LINUX_DIR)/net/ipv4/netfilter/nf_defrag_ipv4.ko \
       $(LINUX_DIR)/net/ipv6/netfilter/nf_defrag_ipv6.ko

I can build the package on it's own, but if I try to do a build with my kmod built in, the build will fail with bunch of errors like:

...
        But that file is already provided by package  * kmod-sched-arl
 * opkg_install_cmd: Cannot install package kmod-nf-conntrack6.
 * check_data_file_clashes: Package kmod-nf-conntrack wants to install file /home/sn/openwrt/\
build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/root-ipq806x/lib/modules/5.10.104/nf_con\
ntrack.ko
        But that file is already provided by package  * kmod-sched-arl
 * check_data_file_clashes: Package kmod-nf-conntrack wants to install file /home/sn/openwrt/\
build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/root-ipq806x/lib/modules/5.10.104/nf_def\
rag_ipv4.ko
        But that file is already provided by package  * kmod-sched-arl
 * check_data_file_clashes: Package kmod-nf-conntrack wants to install file /home/sn/openwrt/\
build_dir/target-arm_cortex-a15+neon-vfpv4_musl_eabi/root-ipq806x/lib/modules/5.10.104/nf_def\
rag_ipv6.ko
...

plus some others I did not expect.

What is the proper way to handle out of tree kmod dependencies?

The openwrt package guide is helpful, but a bit sparse on details. Note for this out of tree kernel module to function, I am patching in tree include files, a Kconfig, and one *.c file.

EDIT: i just noticed that i have an extra DEPENDS:= - I'll try removing that.

Make sure you Require */y the Kmod package,rather than {M}, or it won't include it in the image directly. It's a bit counter-intuitive, at least for me, because you've got to Require to Include something that ultimately is modularized.

If I don't make silly errors like leaving an empty DEPENDS:= statements in my Makefile, then every builds fine. Who would have thought.

But thankyou @Grommish for taking a look.

EDIT I don't need the additional nf_conntract.ko or others in case someone else finds their way here.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.