dkms icon indicating copy to clipboard operation
dkms copied to clipboard

Skip building modules for incompatible kernel configs

Open xnox opened this issue 2 years ago • 4 comments

In Ubuntu, we ship various dkms modules and we also have many different kernel types.

Some dkms modules target hardware & kernels that require certain configuration options to be enabled in the kernel. Most of Ubuntu kernels have those options turned on, but not others.

At the same time when developing kernels we test a cross combination of all dkms modules against all kernel modules.

It would be nice to have something like a BUILD_EXCLUSIVE_KERNEL= option but something along the lines of BUILD_REQUIRED_CONFIG= such that one can do something like

BUILD_REQUIRED_CONFIG=CONFIG_ACPI

And if a given kernel doesn't have ACPI turned on, dkms module build will not be attempted and instead it would be skipped, declaring that this dkms module is incompatible with a given kernel.

Ditto other scenarios similar to that one - i.e. when dkms module plugs into a wider kernel framework that might be turned off in a given kernel. For example dahdi-linux dkms unable to be built against kernels that have CONFIG_AUDIO turned off.

Or can you please suggest any other options as to how dkms.conf can include some kernel config validation checks (either declarative or scripts) which are not based on kernel version number; but based on kernel config features.

xnox avatar Mar 24 '22 13:03 xnox

I ended up doing:

if ! grep -q '^CONFIG_ECHO=[ym]$' $kernel_source_dir/.config || ! grep -q '^CONFIG_FW_LOADER=[ym]$' $kernel_source_dir/.config; then
BUILD_EXCLUSIVE_KERNEL="^$"
fi

Not sure if this is the best way.

xnox avatar Mar 25 '22 14:03 xnox

There is also the other way around, i.e. a certain configuration must not be enabled. E.g. the zfs and nvidia modules cannot be built on PREEMPT_RT kernels (due to transitive usage of GPL-only symbols).

Could perhaps be modeled as BUILD_REQUIRED_CONFIG="!CONFIG_PREEMPT_RT"

In general, this should allow a space (or comma) separated list of (negated) options.

anbe42 avatar Jun 03 '22 12:06 anbe42

A preliminary patch that adds a (yet undocumented) BUILD_EXCLUSIVE_CONFIG option can be found here: https://gist.github.com/anbe42/66aacc5a4ee1c91089cf11f02d677e3f

anbe42 avatar Jun 13 '22 14:06 anbe42

Can you make a pull request with the updated option also in the man page? thanks.

scaronni avatar Aug 08 '22 19:08 scaronni

@anbe42 seems like this landed in Debian. As mentioned above - can you make this a proper PR and while also updating the manual page?

evelikov avatar Oct 21 '22 19:10 evelikov

See pull request #269.

anbe42 avatar Oct 26 '22 12:10 anbe42