Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 42 additions & 20 deletions config/always-compiler-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,34 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH], [
AC_SUBST([NO_FORMAT_ZERO_LENGTH])
])

dnl #
dnl # Check if kernel cc supports -Wno-format-zero-length option.
dnl #
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_FORMAT_ZERO_LENGTH], [
saved_cc="$CC"
AS_IF(
[ test -n "$KERNEL_CC" ], [ CC="$KERNEL_CC" ],
[ test -n "$KERNEL_LLVM" ], [ CC="clang" ],
[ CC="gcc" ]
)
AC_MSG_CHECKING([whether $CC supports -Wno-format-zero-length])

saved_flags="$CFLAGS"
CFLAGS="$CFLAGS -Werror -Wno-format-zero-length"

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
KERNEL_NO_FORMAT_ZERO_LENGTH=-Wno-format-zero-length
AC_MSG_RESULT([yes])
], [
KERNEL_NO_FORMAT_ZERO_LENGTH=
AC_MSG_RESULT([no])
])

CC="$saved_cc"
CFLAGS="$saved_flags"
AC_SUBST([KERNEL_NO_FORMAT_ZERO_LENGTH])
])

dnl #
dnl # Check if cc supports -Wno-clobbered option.
dnl #
Expand Down Expand Up @@ -231,20 +259,17 @@ dnl #
dnl # Check if kernel cc supports -Winfinite-recursion option.
dnl #
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_INFINITE_RECURSION], [
AC_MSG_CHECKING([whether $KERNEL_CC supports -Winfinite-recursion])

saved_cc="$CC"
AS_IF(
[ test -n "$KERNEL_CC" ], [ CC="$KERNEL_CC" ],
[ test -n "$KERNEL_LLVM" ], [ CC="clang" ],
[ CC="gcc" ]
)
AC_MSG_CHECKING([whether $CC supports -Winfinite-recursion])

saved_flags="$CFLAGS"
CC="gcc"
CFLAGS="$CFLAGS -Werror -Winfinite-recursion"

AS_IF([ test -n "$KERNEL_CC" ], [
CC="$KERNEL_CC"
])
AS_IF([ test -n "$KERNEL_LLVM" ], [
CC="clang"
])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
KERNEL_INFINITE_RECURSION=-Winfinite-recursion
AC_DEFINE([HAVE_KERNEL_INFINITE_RECURSION], 1,
Expand Down Expand Up @@ -329,20 +354,17 @@ dnl #
dnl # Check if kernel cc supports -fno-ipa-sra option.
dnl #
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA], [
AC_MSG_CHECKING([whether $KERNEL_CC supports -fno-ipa-sra])

saved_cc="$CC"
AS_IF(
[ test -n "$KERNEL_CC" ], [ CC="$KERNEL_CC" ],
[ test -n "$KERNEL_LLVM" ], [ CC="clang" ],
[ CC="gcc" ]
)
AC_MSG_CHECKING([whether $CC supports -fno-ipa-sra])

saved_flags="$CFLAGS"
CC="gcc"
CFLAGS="$CFLAGS -Werror -fno-ipa-sra"

AS_IF([ test -n "$KERNEL_CC" ], [
CC="$KERNEL_CC"
])
AS_IF([ test -n "$KERNEL_LLVM" ], [
CC="clang"
])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
KERNEL_NO_IPA_SRA=-fno-ipa-sra
AC_MSG_RESULT([yes])
Expand Down
1 change: 1 addition & 0 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH
ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_FORMAT_ZERO_LENGTH
ZFS_AC_CONFIG_ALWAYS_CC_FORMAT_OVERFLOW
ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA
Expand Down
2 changes: 1 addition & 1 deletion module/Kbuild.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

ifneq ($(KBUILD_EXTMOD),)
zfs_include = @abs_top_srcdir@/include
Expand Down
Loading