Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: cleanup $KERNEL_CC checks #16997

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
@@ -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 #
@@ -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,
@@ -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])
1 change: 1 addition & 0 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
@@ -216,6 +216,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
2 changes: 1 addition & 1 deletion module/Kbuild.in
Original file line number Diff line number Diff line change
@@ -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