Kernel & Driver Build Environments

How to build the kernel driver and out-of-tree modules like amdgpu across kernel versions in CI, covering Kbuild, vermagic/ABI, DKMS, cross-compiling, and Secure Boot signing.

Overview

Building Against the Kernel, Not Against libc

An out-of-tree kernel module is not a normal C program. It has no libc, no dynamic linker, and no stable ABI. It is compiled against one specific prepared kernel tree and is only guaranteed to load into a kernel built from that exact tree, with that exact .config and compiler. This is why amdgpu built for 6.8.0-31-generic refuses to load on 6.8.0-35-generic with invalid module format, even though the two version strings look almost identical.

Key concepts

  • Kbuild and obj-m
  • kernel-devel / linux-headers vs full source
  • vermagic
  • Module versioning (modversions / Module.symvers)
  • DKMS (Dynamic Kernel Module Support)
  • ARCH and CROSS_COMPILE
  • Module signing and Secure Boot

Interview questions

  • How do you build an out-of-tree module in CI across a matrix of kernel versions?
  • How do you package a driver with DKMS so it survives kernel upgrades?
  • How do you diagnose a vermagic/ABI mismatch at load time?
  • How do you cross-compile a driver for aarch64 from an x86_64 runner?
  • How do you sign modules so they load on a Secure Boot host?
  • How do you handle NFS-mounted kernel headers and toolchains on the runner, and keep builds reproducible?

Sign up free to read the full topic

More Linux topics

Start free on Cariara · Coding problems · System design studio