freenode
Kernel & Low-Level

Kernel builds may start compiling tools and selftests

Sasha Levin wants allmodconfig to catch userspace breakage that currently slips past bots, but Andrew Morton says module-loading tests still have a separate problem.

Sasha Levin has proposed folding selected programs under the kernel's tools tree into the ordinary kernel build, so the checks most developers and build bots already run would notice when those programs stop compiling.

Today, almost nothing under tools/ is part of a kernel build. Each program has its own makefiles. Apart from a few host utilities the build itself needs, such as objtool, a change is typically tested with an allmodconfig build that never compiles them. Levin wrote that broken selftests then sit unnoticed until someone builds them by hand, sometimes many stable releases later. The same complaint came up at the Linux Plumbers Conference.

The series adds a configuration menu, on by default for allmodconfig and allyesconfig when the compiler can link glibc programs, currently only on x86_64 and arm64. A new tools_build target compiles the selected programs for the same target as the kernel, using each tool's existing build system. With the option set, a full kernel build includes them. Builds of just the kernel image, modules, or out-of-tree modules are left alone, as are toolchains without a C library.

The first tools are the ones that need only libc, including perf. Perf can be built in a minimal mode that disables optional features, so a build machine missing libraries such as libelf does not fail a test build. A selftest submenu covers tests that likewise need only a C library and do not write into the source tree. Levin noted that most of those tests still depend on a makefile fix that is not in mainline.

One limit is easy to miss. As with the existing selftest build, a selftest that fails to compile does not fail the kernel build unless the build is forced to treat that as an error.

Andrew Morton replied the same day with a separate complaint. CONFIG_TRIM_UNUSED_KSYMS drops exports that the current set of modules does not use. Selftests that build a module and then load it can then fail at modprobe, because an export they need was removed. He asked whether the series fixes that. The patches as posted build selftests; they do not run them, and they do not describe feeding those test modules into the export whitelist.