Skip to content

Conversation

@tzafrir-mellanox
Copy link

@tzafrir-mellanox tzafrir-mellanox commented Apr 28, 2025

Kernel is configured by querying the kernel build system directly, and
kernel directory can be built independetly of autoconf.

This solves several separate issues:

  • Having to carry all of autoconf to the DKMS directory
  • The compiler that autoconf detects by default may not be the one
    that the kernel needs.
    • It is even OK to not have "gcc" and have "gcc-14" if that is what
      the kernel needs, but autoconf will still be picky.
  • Various other issues are best detected by the kernel build system
    directly, and not trying ot second-guess it, as this occasionally
    changes.
    • One exception: clang support requires explicitly setting
      LLVM=1 . Not done automatically for now.

Changes:

  • m4/ac_kernel_checks.m4 has mostly been replaced by the script
    kernel/config_kernel
    • This script can also be run manually. See dkms.conf .
    • The script does not include tests. They are in files under
      kernel/test_cases/
    • kernel/ can be run without autoconf: kernel/Kbuild was simplified.
    • And alternative Makefile for it is provided as kernel/Makefile.dkms
  • Using relative path to generated include file rather than path
    in a generated file from autoconf

The test works by creating a kernel module for each test and
building all of them with the kernel build system and with the -k
option of make and check which of them built successfully.

As an initial stage, we run a test build of a single empty module
just to be sure that the build system works.

To simplify debugging, kernel tests can be re-run separately (after
main script was run) using e.g.:

kernel/config_kernel HAVE_PUD_LEAF_MACRO

Kernel is configured by querying the kernel build system directly, and
kernel directory can be built independetly of autoconf.

This solves several separate issues:
* Having to carry all of autoconf to the DKMS directory
* The compiler that autoconf detects by default may not be the one
  that the kernel needs.
  - It is even OK to not have "gcc" and have "gcc-14" if that is what
    the kernel needs, but autoconf will still be picky.
* Various other issues are best detected by the kernel build system
  directly, and not trying ot second-guess it, as this occasionally
  changes.
  - One exception: clang support requires explicitly setting
    LLVM=1 . Not done automatically for now.

Changes:
* m4/ac_kernel_checks.m4 has mostly been replaced by the script
  kernel/config_kernel
  - This script can also be run manually. See dkms.conf .
  - The script does not include tests. They are in files under
    kernel/test_cases/
  - kernel/ can be run without autoconf: kernel/Kbuild was simplified.
  - And alternative Makefile for it is provided as kernel/Makefile.dkms
* Using relative path to generated include file rather than path
  in a generated file from autoconf

The test works by creating a kernel module for each test and
building all of them with the kernel build system and with the -k
option of make and check which of them built successfully.

As an initial stage, we run a test build of a single empty module
just to be sure that the build system works.

To simplify debugging, kernel tests can be re-run separately (after
main script was run) using e.g.:

  kernel/config_kernel HAVE_PUD_LEAF_MACRO
@tzafrir-mellanox tzafrir-mellanox changed the title kernel: draft of alternative configuration kernel: alternative configuration Jan 12, 2026
@tzafrir-mellanox
Copy link
Author

Some notes:

  • On my system, configure script runs slightly faster: tests are slower to run than original configure (though more reliable), but are run in parallel (by the kernel build system).
  • This change may break out-of-tree builds. Do you have any existing users of such? If so, I can test and try to fix.
  • I opted to include tests in multiple files. Alternatively, it is possible to embed them in a autoconf m4 file. This is how it's done in mlnx-ofa_kernel (compat/config/rdma.m4). But if you prefer it that way, it could be changed.
  • As noted, mlnx-ofa_kernel already has various tests of kernel features in basically the same format that we can use, if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant