]> git.proxmox.com Git - mirror_zfs.git/commitdiff
config: check for -Wno-cast-function-type
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Fri, 25 Feb 2022 17:49:29 +0000 (17:49 +0000)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 26 Feb 2022 19:26:55 +0000 (11:26 -0800)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #13145
Closes #13152

config/always-compiler-options.m4
config/zfs-build.m4
lib/libzpool/Makefile.am

index bf96313d90be7fd131c641f1e79fc3258b2d2c54..c0f6e076dce1de2d3fbc396054a8f75caf3953e3 100644 (file)
@@ -181,6 +181,32 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_CLOBBERED], [
        AC_SUBST([NO_CLOBBERED])
 ])
 
+dnl #
+dnl # Check if gcc supports -Wno-cast-function-type option.
+dnl #
+dnl # We actually invoke gcc with the --cast-function-type option
+dnl # and infer the 'no-' version does or doesn't exist based upon
+dnl # the results.  This is required because when checking any of
+dnl # no- prefixed options gcc always returns success.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_CAST_FUNCTION_TYPE], [
+       AC_MSG_CHECKING([whether $CC supports -Wno-cast-function-type])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Werror -Wcast-function-type"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               NO_CAST_FUNCTION_TYPE=-Wno-cast-function-type
+               AC_MSG_RESULT([yes])
+       ], [
+               NO_CAST_FUNCTION_TYPE=
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+       AC_SUBST([NO_CAST_FUNCTION_TYPE])
+])
+
 dnl #
 dnl # Check if gcc supports -Wimplicit-fallthrough option.
 dnl #
index d516f3d2969f3ddc912ddbf18413353fa9928f23..42e57cdf7a336a81411409ddbaec282b957409fb 100644 (file)
@@ -210,6 +210,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
        AC_SUBST(CPU_COUNT)
 
        ZFS_AC_CONFIG_ALWAYS_CC_NO_CLOBBERED
+       ZFS_AC_CONFIG_ALWAYS_CC_NO_CAST_FUNCTION_TYPE
        ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH
        ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
        ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
index 3942ff3b6d74f73fc3d0c415625d7f1aa6226d06..60ffbb7ee51f8dec7c1b2bdac21ec23bb56be6d7 100644 (file)
@@ -26,8 +26,8 @@ AM_CFLAGS += -DLIB_ZPOOL_BUILD
 
 # For the void (*)(void *) -> void *(*)(void *) cast in zk_thread_create()
 # See https://github.com/openzfs/zfs/pull/13110#discussion_r808450136
-kernel.$(OBJEXT): CFLAGS += -Wno-cast-function-type
-kernel.l$(OBJEXT): CFLAGS += -Wno-cast-function-type
+kernel.$(OBJEXT): CFLAGS += $(NO_CAST_FUNCTION_TYPE)
+kernel.l$(OBJEXT): CFLAGS += $(NO_CAST_FUNCTION_TYPE)
 
 lib_LTLIBRARIES = libzpool.la