OpenAFS Master Repository branch, master, updated. openafs-devel-1_9_2-417-gaacf65b
Gerrit Code Review
gerrit@openafs.org
Tue, 20 Jan 2026 15:48:32 -0500
The following commit has been merged in the master branch:
commit aacf65b02b38a6a19d74a20147963980d6831e87
Author: Cheyenne Wills <cwills@sinenomine.net>
Date: Tue Dec 16 18:36:27 2025 -0700
cf: Linux kernel compiler version checks
When building the Linux kernel module, the compiler version should match
the compiler version that was used to build the Linux kernel itself.
Using a different compiler or a significantly different version may lead
to unexpected results. While modern Linux build systems do perform a
compiler version check, the output is often filtered out or suppressed
by the OpenAFS configure and kernel module build steps, hiding potential
mismatches from the user. Furthermore, an incompatible compiler may
cause silent failures in the configure tests used to determine kernel
features.
To avoid introducing complex checks within the existing kernel feature
tests, a new configure check is added that runs before any other kernel
module build tests. This new check first extracts the compiler version
used to build the kernel by checking .config or falling back to header
files for older kernels. It then determines the compiler version that
will be used to build the module by invoking the kbuild process.
Finally, it compares the versions, if there are differences it will
log the differences, and issue warnings if the compiler type (e.g. gcc
vs clang) or the major version (e.g. gcc-13 vs gcc-15) of the compiler
are different. If the difference is just the minor version (e.g.
gcc-13.2 vs gcc-13.5), the log will note that the compilers are
different versions, but no warnings will be logged.
The Linux kernel kbuild process may also generate warnings or errors;
if these are detected, the stderr from the kbuild will be added to the
config.log. Some of the information produced by the kbuild process
may duplicate the information generated by the configure check. The
Linux kernel kbuild process may also report a difference if the exact
name of the compiler doesn't match, even though the compiler types and
compiler versions are the same.
The check is designed to be informational; it issues informational and
warning messages but does not halt the configure process. These messages
can aid in problem determination if the kernel module build process
fails.
Add a new macro LINUX_KBUILD_COMPILER_CHECK and helper routines to a new
file, src/cf/linux-kernel-compiler.m4. The call to this new check is
inserted before the existing kernel build checks. Update the configure
summary to display both the kernel's compiler version and the module
build compiler version.
Notes:
Current Linux kernels place the compiler version within the .config
file (Linux >= 5.8), while older versions placed the compiler version
within a header file (whose location was changed at least once
between 2.6.18 and 5.8).
Determining the compiler version that will be used for building the
kernel module requires running the compiler within the kernel kbuild
process. Use the gnu make $(shell ...) feature to run the compiler and
the $(info ...) feature to display the result (these features are also
used by the Linux kbuild processes).
Example logging output:
* configure console with the same compiler
...
checking whether C compiler accepts -pipe... yes
checking kernel compiler versions... same
checking how to set cflags for linux kbuild... ccflags-y
...
Linux kernel module
...
kernel compiled with : gcc (Gentoo 14.3.1_p20250801 p4) 14.3.1 20250801
module C compiler : gcc (Gentoo 14.3.1_p20250801 p4) 14.3.1 20250801
..
* config.log with the same compiler:
...
configure:20227: checking kernel compiler versions
configure:20356: result: same
...
* configure console where the compiler has a major version difference:
...
checking whether C compiler accepts -pipe... yes
checking kernel compiler versions... configure: kernel compiler versions are different, see config.log
configure: WARNING: Compiler major versions differ, kernel module may be unusable
different
checking how to set cflags for linux kbuild... ccflags-y
...
Linux kernel module
...
kernel compiled with : gcc (Gentoo 14.3.1_p20250801 p4) 14.3.1 20250801
module C compiler : gcc-15 (Gentoo 15.2.1_p20251122 p4) 15.2.1 20251122
...
* config.log where the compiler has a major version difference
...
configure:20227: checking kernel compiler versions
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (Gentoo 14.3.1_p20250801 p4) 14.3.1 20250801
You are using: gcc-15 (Gentoo 15.2.1_p20251122 p4) 15.2.1 20251122
configure:20359: kernel compiler versions are different, see config.log
kernel compiled with : gcc (Gentoo 14.3.1_p20250801 p4) 14.3.1 20250801
kmod compiling with : gcc-15 (Gentoo 15.2.1_p20251122 p4) 15.2.1 20251122
configure:20370: WARNING: Compiler major versions differ, kernel module may be unusable
configure:20373: result: different
Change-Id: I8b37ffde14579726ab4e3443b54c84f9edf7f9a1
Reviewed-on: https://gerrit.openafs.org/16655
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
src/cf/linux-checks.m4 | 1 +
src/cf/linux-kernel-compiler.m4 | 106 ++++++++++++++++++++++++++++++++++++++++
src/cf/summary.m4 | 2 +
3 files changed, 109 insertions(+)
--
OpenAFS Master Repository