2018-01-10 18:49:27 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Enabled -fsanitize=address if supported by gcc.
|
|
|
|
dnl #
|
|
|
|
dnl # LDFLAGS needs -fsanitize=address at all times so libraries compiled with
|
|
|
|
dnl # it will be linked successfully. CFLAGS will vary by binary being built.
|
|
|
|
dnl #
|
|
|
|
dnl # The ASAN_OPTIONS environment variable can be used to further control
|
|
|
|
dnl # the behavior of binaries and libraries build with -fsanitize=address.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_ASAN], [
|
|
|
|
AC_MSG_CHECKING([whether to build with -fsanitize=address support])
|
|
|
|
AC_ARG_ENABLE([asan],
|
|
|
|
[AS_HELP_STRING([--enable-asan],
|
|
|
|
[Enable -fsanitize=address support @<:@default=no@:>@])],
|
|
|
|
[],
|
|
|
|
[enable_asan=no])
|
|
|
|
|
|
|
|
AM_CONDITIONAL([ASAN_ENABLED], [test x$enable_asan = xyes])
|
|
|
|
AC_SUBST([ASAN_ENABLED], [$enable_asan])
|
|
|
|
AC_MSG_RESULT($enable_asan)
|
|
|
|
|
|
|
|
AS_IF([ test "$enable_asan" = "yes" ], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -fsanitize=address])
|
|
|
|
saved_cflags="$CFLAGS"
|
2020-02-04 16:47:38 +00:00
|
|
|
CFLAGS="$CFLAGS -Werror -fsanitize=address"
|
2018-01-10 18:49:27 +00:00
|
|
|
AC_LINK_IFELSE([
|
|
|
|
AC_LANG_SOURCE([[ int main() { return 0; } ]])
|
|
|
|
], [
|
|
|
|
ASAN_CFLAGS="-fsanitize=address"
|
|
|
|
ASAN_LDFLAGS="-fsanitize=address"
|
|
|
|
ASAN_ZFS="_with_asan"
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
AC_MSG_ERROR([$CC does not support -fsanitize=address])
|
|
|
|
])
|
|
|
|
CFLAGS="$saved_cflags"
|
|
|
|
], [
|
|
|
|
ASAN_CFLAGS=""
|
|
|
|
ASAN_LDFLAGS=""
|
|
|
|
ASAN_ZFS="_without_asan"
|
|
|
|
])
|
|
|
|
|
|
|
|
AC_SUBST([ASAN_CFLAGS])
|
|
|
|
AC_SUBST([ASAN_LDFLAGS])
|
|
|
|
AC_SUBST([ASAN_ZFS])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Check if gcc supports -Wframe-larger-than=<size> option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -Wframe-larger-than=<size>])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
2020-02-04 16:47:38 +00:00
|
|
|
CFLAGS="$CFLAGS -Werror -Wframe-larger-than=4096"
|
2018-01-10 18:49:27 +00:00
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
FRAME_LARGER_THAN="-Wframe-larger-than=4096"
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
FRAME_LARGER_THAN=""
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([FRAME_LARGER_THAN])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Check if gcc supports -Wno-format-truncation option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -Wno-format-truncation])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
2020-02-04 16:47:38 +00:00
|
|
|
CFLAGS="$CFLAGS -Werror -Wno-format-truncation"
|
2018-01-10 18:49:27 +00:00
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
NO_FORMAT_TRUNCATION=-Wno-format-truncation
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
NO_FORMAT_TRUNCATION=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([NO_FORMAT_TRUNCATION])
|
|
|
|
])
|
|
|
|
|
2020-04-14 18:36:28 +00:00
|
|
|
dnl #
|
2022-02-16 15:06:08 +00:00
|
|
|
dnl # Check if gcc supports -Wno-format-zero-length option.
|
2020-04-14 18:36:28 +00:00
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH], [
|
|
|
|
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([], [])], [
|
|
|
|
NO_FORMAT_ZERO_LENGTH=-Wno-format-zero-length
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
NO_FORMAT_ZERO_LENGTH=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([NO_FORMAT_ZERO_LENGTH])
|
|
|
|
])
|
|
|
|
|
2018-01-10 18:49:27 +00:00
|
|
|
dnl #
|
2022-02-16 15:06:08 +00:00
|
|
|
dnl # Check if gcc supports -Wno-clobbered option.
|
2018-01-10 18:49:27 +00:00
|
|
|
dnl #
|
2022-02-16 15:06:08 +00:00
|
|
|
dnl # We actually invoke gcc with the -Wclobbered option
|
2018-01-10 18:49:27 +00:00
|
|
|
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 #
|
2022-02-16 15:06:08 +00:00
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_CLOBBERED], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -Wno-clobbered])
|
2018-01-10 18:49:27 +00:00
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
2022-02-16 15:06:08 +00:00
|
|
|
CFLAGS="$CFLAGS -Werror -Wclobbered"
|
2018-01-10 18:49:27 +00:00
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
2022-02-16 15:06:08 +00:00
|
|
|
NO_CLOBBERED=-Wno-clobbered
|
2018-01-10 18:49:27 +00:00
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
2022-02-16 15:06:08 +00:00
|
|
|
NO_CLOBBERED=
|
2018-01-10 18:49:27 +00:00
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
2022-02-16 15:06:08 +00:00
|
|
|
AC_SUBST([NO_CLOBBERED])
|
2018-01-10 18:49:27 +00:00
|
|
|
])
|
2019-04-14 18:04:54 +00:00
|
|
|
|
2021-09-14 16:17:54 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Check if gcc supports -Wimplicit-fallthrough option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -Wimplicit-fallthrough])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Werror -Wimplicit-fallthrough"
|
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
IMPLICIT_FALLTHROUGH=-Wimplicit-fallthrough
|
|
|
|
AC_DEFINE([HAVE_IMPLICIT_FALLTHROUGH], 1,
|
|
|
|
[Define if compiler supports -Wimplicit-fallthrough])
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
IMPLICIT_FALLTHROUGH=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([IMPLICIT_FALLTHROUGH])
|
|
|
|
])
|
|
|
|
|
2022-06-20 19:53:58 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Check if cc supports -Winfinite-recursion option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_INFINITE_RECURSION], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -Winfinite-recursion])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Werror -Winfinite-recursion"
|
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
INFINITE_RECURSION=-Winfinite-recursion
|
|
|
|
AC_DEFINE([HAVE_INFINITE_RECURSION], 1,
|
|
|
|
[Define if compiler supports -Winfinite-recursion])
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
INFINITE_RECURSION=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([INFINITE_RECURSION])
|
|
|
|
])
|
|
|
|
|
2022-11-30 10:27:28 +00:00
|
|
|
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"
|
|
|
|
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,
|
|
|
|
[Define if compiler supports -Winfinite-recursion])
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
KERNEL_INFINITE_RECURSION=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CC="$saved_cc"
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([KERNEL_INFINITE_RECURSION])
|
|
|
|
])
|
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Check if cc supports -Wformat-overflow option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_FORMAT_OVERFLOW], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -Wformat-overflow])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Werror -Wformat-overflow"
|
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
FORMAT_OVERFLOW=-Wformat-overflow
|
|
|
|
AC_DEFINE([HAVE_FORMAT_OVERFLOW], 1,
|
|
|
|
[Define if compiler supports -Wformat-overflow])
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
FORMAT_OVERFLOW=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([FORMAT_OVERFLOW])
|
|
|
|
])
|
|
|
|
|
2019-04-14 18:04:54 +00:00
|
|
|
dnl #
|
|
|
|
dnl # Check if gcc supports -fno-omit-frame-pointer option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -fno-omit-frame-pointer])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
2020-02-04 16:47:38 +00:00
|
|
|
CFLAGS="$CFLAGS -Werror -fno-omit-frame-pointer"
|
2019-04-14 18:04:54 +00:00
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
NO_OMIT_FRAME_POINTER=-fno-omit-frame-pointer
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
NO_OMIT_FRAME_POINTER=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([NO_OMIT_FRAME_POINTER])
|
|
|
|
])
|
2020-02-06 17:24:37 +00:00
|
|
|
|
|
|
|
dnl #
|
|
|
|
dnl # Check if cc supports -fno-ipa-sra option.
|
|
|
|
dnl #
|
|
|
|
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA], [
|
|
|
|
AC_MSG_CHECKING([whether $CC supports -fno-ipa-sra])
|
|
|
|
|
|
|
|
saved_flags="$CFLAGS"
|
|
|
|
CFLAGS="$CFLAGS -Werror -fno-ipa-sra"
|
|
|
|
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
|
|
|
|
NO_IPA_SRA=-fno-ipa-sra
|
|
|
|
AC_MSG_RESULT([yes])
|
|
|
|
], [
|
|
|
|
NO_IPA_SRA=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([NO_IPA_SRA])
|
|
|
|
])
|
2022-11-30 10:27:28 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
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])
|
|
|
|
], [
|
|
|
|
KERNEL_NO_IPA_SRA=
|
|
|
|
AC_MSG_RESULT([no])
|
|
|
|
])
|
|
|
|
|
|
|
|
CC="$saved_cc"
|
|
|
|
CFLAGS="$saved_flags"
|
|
|
|
AC_SUBST([KERNEL_NO_IPA_SRA])
|
|
|
|
])
|