diff options
author | наб <nabijaczleweli@nabijaczleweli.xyz> | 2022-02-25 17:49:29 +0000 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2022-02-26 11:26:55 -0800 |
commit | 1ea68b6d38d8e20e53e813b6a9d5d68f4c7cd838 (patch) | |
tree | 85a19041d7dddebcc764e26fbad331e09d0ec3fc | |
parent | 82226e4f44baa3f7c3101caaaf941927aa318e46 (diff) |
config: check for -Wno-cast-function-type
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
-rw-r--r-- | config/always-compiler-options.m4 | 26 | ||||
-rw-r--r-- | config/zfs-build.m4 | 1 | ||||
-rw-r--r-- | lib/libzpool/Makefile.am | 4 |
3 files changed, 29 insertions, 2 deletions
diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4 index bf96313d9..c0f6e076d 100644 --- a/config/always-compiler-options.m4 +++ b/config/always-compiler-options.m4 @@ -182,6 +182,32 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_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 # AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH], [ diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index d516f3d29..42e57cdf7 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -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 diff --git a/lib/libzpool/Makefile.am b/lib/libzpool/Makefile.am index 3942ff3b6..60ffbb7ee 100644 --- a/lib/libzpool/Makefile.am +++ b/lib/libzpool/Makefile.am @@ -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 |