Skip to content

Commit 14bad10

Browse files
intelfxbehlendorf
authored andcommitted
config: add and use KERNEL_CC check for -Wno-format-zero-length
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ivan Shapovalov <[email protected]> Closes #16997
1 parent e903177 commit 14bad10

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

config/always-compiler-options.m4

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,34 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH], [
155155
AC_SUBST([NO_FORMAT_ZERO_LENGTH])
156156
])
157157

158+
dnl #
159+
dnl # Check if kernel cc supports -Wno-format-zero-length option.
160+
dnl #
161+
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_FORMAT_ZERO_LENGTH], [
162+
saved_cc="$CC"
163+
AS_IF(
164+
[ test -n "$KERNEL_CC" ], [ CC="$KERNEL_CC" ],
165+
[ test -n "$KERNEL_LLVM" ], [ CC="clang" ],
166+
[ CC="gcc" ]
167+
)
168+
AC_MSG_CHECKING([whether $CC supports -Wno-format-zero-length])
169+
170+
saved_flags="$CFLAGS"
171+
CFLAGS="$CFLAGS -Werror -Wno-format-zero-length"
172+
173+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
174+
KERNEL_NO_FORMAT_ZERO_LENGTH=-Wno-format-zero-length
175+
AC_MSG_RESULT([yes])
176+
], [
177+
KERNEL_NO_FORMAT_ZERO_LENGTH=
178+
AC_MSG_RESULT([no])
179+
])
180+
181+
CC="$saved_cc"
182+
CFLAGS="$saved_flags"
183+
AC_SUBST([KERNEL_NO_FORMAT_ZERO_LENGTH])
184+
])
185+
158186
dnl #
159187
dnl # Check if cc supports -Wno-clobbered option.
160188
dnl #

config/zfs-build.m4

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
256256
ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
257257
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
258258
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH
259+
ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_FORMAT_ZERO_LENGTH
259260
ZFS_AC_CONFIG_ALWAYS_CC_FORMAT_OVERFLOW
260261
ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
261262
ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA

module/Kbuild.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
66
ZFS_MODULE_CFLAGS += -Wmissing-prototypes
7-
ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @NO_FORMAT_ZERO_LENGTH@
7+
ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@ @KERNEL_NO_FORMAT_ZERO_LENGTH@
88

99
ifneq ($(KBUILD_EXTMOD),)
1010
zfs_include = @abs_top_srcdir@/include

0 commit comments

Comments
 (0)