Skip to content

Commit 72d16a9

Browse files
solbjorntonyhutter
authored andcommitted
Linux 5.15 compat: standalone <linux/stdarg.h>
Kernel commits 39f75da7bcc8 ("isystem: trim/fixup stdarg.h and other headers") c0891ac15f04 ("isystem: ship and use stdarg.h") 564f963eabd1 ("isystem: delete global -isystem compile option") (for now can be found in linux-next.git tree, will land into the Linus' tree during the ongoing 5.15 cycle with one of akpm merges) removed the -isystem flag and disallowed the inclusion of any compiler header files. They also introduced a minimal <linux/stdarg.h> as a replacement for <stdarg.h>. include/os/linux/spl/sys/cmn_err.h in the ZFS source tree includes <stdarg.h> unconditionally. Introduce a test for <linux/stdarg.h> and include it instead of the compiler's one to prevent module build breakage. Reviewed-by: Tony Nguyen <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Lobakin <[email protected]> Closes #12531
1 parent 54c358c commit 72d16a9

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

config/kernel-stdarg.m4

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
dnl #
2+
dnl # Linux 5.15 gets rid of -isystem and external <stdarg.h> inclusion
3+
dnl # and ships its own <linux/stdarg.h>. Check if this header file does
4+
dnl # exist and provide all necessary definitions for variable argument
5+
dnl # functions. Adjust the inclusion of <stdarg.h> according to the
6+
dnl # results.
7+
dnl #
8+
AC_DEFUN([ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG], [
9+
ZFS_LINUX_TEST_SRC([has_standalone_linux_stdarg], [
10+
#include <linux/stdarg.h>
11+
12+
#if !defined(va_start) || !defined(va_end) || \
13+
!defined(va_arg) || !defined(va_copy)
14+
#error "<linux/stdarg.h> is invalid"
15+
#endif
16+
],[])
17+
])
18+
19+
AC_DEFUN([ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG], [
20+
dnl #
21+
dnl # Linux 5.15 ships its own stdarg.h and doesn't allow to
22+
dnl # include compiler headers.
23+
dnl #
24+
AC_MSG_CHECKING([whether standalone <linux/stdarg.h> exists])
25+
ZFS_LINUX_TEST_RESULT([has_standalone_linux_stdarg], [
26+
AC_MSG_RESULT([yes])
27+
AC_DEFINE(HAVE_STANDALONE_LINUX_STDARG, 1,
28+
[standalone <linux/stdarg.h> exists])
29+
],[
30+
AC_MSG_RESULT([no])
31+
])
32+
])

config/kernel.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
132132
ZFS_AC_KERNEL_SRC_SIGINFO
133133
ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE
134134
ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS
135+
ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG
135136
136137
AC_MSG_CHECKING([for available kernel interfaces])
137138
ZFS_LINUX_TEST_COMPILE_ALL([kabi])
@@ -237,6 +238,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
237238
ZFS_AC_KERNEL_SIGINFO
238239
ZFS_AC_KERNEL_SET_SPECIAL_STATE
239240
ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS
241+
ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG
240242
])
241243

242244
dnl #

include/os/linux/spl/sys/cmn_err.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
#ifndef _SPL_CMN_ERR_H
2525
#define _SPL_CMN_ERR_H
2626

27+
#if defined(_KERNEL) && defined(HAVE_STANDALONE_LINUX_STDARG)
28+
#include <linux/stdarg.h>
29+
#else
2730
#include <stdarg.h>
31+
#endif
2832

2933
#define CE_CONT 0 /* continuation */
3034
#define CE_NOTE 1 /* notice */

0 commit comments

Comments
 (0)