diff options
author | Alexander <solbjorn@users.noreply.github.com> | 2021-09-08 21:59:43 +0200 |
---|---|---|
committer | Tony Hutter <hutter2@llnl.gov> | 2021-09-22 15:19:08 -0700 |
commit | 72d16a9b49f54a44a471f881d767621e2bfbe913 (patch) | |
tree | afdef45bf41d14f00dac5d7e49af0975fc9b8768 | |
parent | 54c358c3f2d3ebd528d8b1b94f96160c9bc065b0 (diff) |
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 <tony.nguyen@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Closes #12531
-rw-r--r-- | config/kernel-stdarg.m4 | 32 | ||||
-rw-r--r-- | config/kernel.m4 | 2 | ||||
-rw-r--r-- | include/os/linux/spl/sys/cmn_err.h | 4 |
3 files changed, 38 insertions, 0 deletions
diff --git a/config/kernel-stdarg.m4 b/config/kernel-stdarg.m4 new file mode 100644 index 000000000..5bc8dd859 --- /dev/null +++ b/config/kernel-stdarg.m4 @@ -0,0 +1,32 @@ +dnl # +dnl # Linux 5.15 gets rid of -isystem and external <stdarg.h> inclusion +dnl # and ships its own <linux/stdarg.h>. Check if this header file does +dnl # exist and provide all necessary definitions for variable argument +dnl # functions. Adjust the inclusion of <stdarg.h> according to the +dnl # results. +dnl # +AC_DEFUN([ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG], [ + ZFS_LINUX_TEST_SRC([has_standalone_linux_stdarg], [ + #include <linux/stdarg.h> + + #if !defined(va_start) || !defined(va_end) || \ + !defined(va_arg) || !defined(va_copy) + #error "<linux/stdarg.h> is invalid" + #endif + ],[]) +]) + +AC_DEFUN([ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG], [ + dnl # + dnl # Linux 5.15 ships its own stdarg.h and doesn't allow to + dnl # include compiler headers. + dnl # + AC_MSG_CHECKING([whether standalone <linux/stdarg.h> exists]) + ZFS_LINUX_TEST_RESULT([has_standalone_linux_stdarg], [ + AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_STANDALONE_LINUX_STDARG, 1, + [standalone <linux/stdarg.h> exists]) + ],[ + AC_MSG_RESULT([no]) + ]) +]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 3433a300a..908c331ce 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -132,6 +132,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_SIGINFO ZFS_AC_KERNEL_SRC_SET_SPECIAL_STATE ZFS_AC_KERNEL_SRC_VFS_SET_PAGE_DIRTY_NOBUFFERS + ZFS_AC_KERNEL_SRC_STANDALONE_LINUX_STDARG AC_MSG_CHECKING([for available kernel interfaces]) ZFS_LINUX_TEST_COMPILE_ALL([kabi]) @@ -237,6 +238,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_SIGINFO ZFS_AC_KERNEL_SET_SPECIAL_STATE ZFS_AC_KERNEL_VFS_SET_PAGE_DIRTY_NOBUFFERS + ZFS_AC_KERNEL_STANDALONE_LINUX_STDARG ]) dnl # diff --git a/include/os/linux/spl/sys/cmn_err.h b/include/os/linux/spl/sys/cmn_err.h index 314bbbaf9..f46efdefa 100644 --- a/include/os/linux/spl/sys/cmn_err.h +++ b/include/os/linux/spl/sys/cmn_err.h @@ -24,7 +24,11 @@ #ifndef _SPL_CMN_ERR_H #define _SPL_CMN_ERR_H +#if defined(_KERNEL) && defined(HAVE_STANDALONE_LINUX_STDARG) +#include <linux/stdarg.h> +#else #include <stdarg.h> +#endif #define CE_CONT 0 /* continuation */ #define CE_NOTE 1 /* notice */ |