diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/Rules.am | 27 | ||||
-rw-r--r-- | config/always-compiler-options.m4 | 141 | ||||
-rw-r--r-- | config/always-no-bool-compare.m4 | 27 | ||||
-rw-r--r-- | config/always-no-unused-but-set-variable.m4 | 27 | ||||
-rw-r--r-- | config/kernel.m4 | 15 | ||||
-rw-r--r-- | config/user-frame-larger-than.m4 | 22 | ||||
-rw-r--r-- | config/user-no-format-truncation.m4 | 22 | ||||
-rw-r--r-- | config/user.m4 | 2 | ||||
-rw-r--r-- | config/zfs-build.m4 | 92 |
9 files changed, 226 insertions, 149 deletions
diff --git a/config/Rules.am b/config/Rules.am index 215f09c34..9a9dd452a 100644 --- a/config/Rules.am +++ b/config/Rules.am @@ -1,18 +1,29 @@ +# +# Default build rules for all user space components, every Makefile.am +# should include these rules and override or extend them as needed. +# + DEFAULT_INCLUDES = -include ${top_builddir}/zfs_config.h AM_LIBTOOLFLAGS = --silent -AM_CFLAGS = ${DEBUG_CFLAGS} -Wall -Wstrict-prototypes -AM_CFLAGS += ${NO_UNUSED_BUT_SET_VARIABLE} -AM_CFLAGS += ${NO_BOOL_COMPARE} -AM_CFLAGS += -fno-strict-aliasing -AM_CFLAGS += -std=gnu99 + +AM_CFLAGS = -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing +AM_CFLAGS += $(DEBUG_CFLAGS) +AM_CFLAGS += $(ASAN_CFLAGS) AM_CFLAGS += $(CODE_COVERAGE_CFLAGS) -AM_CPPFLAGS = -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT -AM_CPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64 -AM_CPPFLAGS += -D_LARGEFILE64_SOURCE -DHAVE_LARGE_STACKS=1 + +AM_CPPFLAGS = -D_GNU_SOURCE +AM_CPPFLAGS += -D_REENTRANT +AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64 +AM_CPPFLAGS += -D_LARGEFILE64_SOURCE +AM_CPPFLAGS += -DHAVE_LARGE_STACKS=1 AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-linux-user\" AM_CPPFLAGS += -DLIBEXECDIR=\"$(libexecdir)\" AM_CPPFLAGS += -DRUNSTATEDIR=\"$(runstatedir)\" AM_CPPFLAGS += -DSBINDIR=\"$(sbindir)\" AM_CPPFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\" +AM_CPPFLAGS += $(DEBUG_CPPFLAGS) AM_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS) + +AM_LDFLAGS = $(DEBUG_LDFLAGS) +AM_LDFLAGS += $(ASAN_LDFLAGS) diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4 new file mode 100644 index 000000000..fcbbf5e76 --- /dev/null +++ b/config/always-compiler-options.m4 @@ -0,0 +1,141 @@ +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" + CFLAGS="$CFLAGS -fsanitize=address" + 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" + CFLAGS="$CFLAGS -Wframe-larger-than=4096" + + 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" + CFLAGS="$CFLAGS -Wno-format-truncation" + + 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]) +]) + + +dnl # +dnl # Check if gcc supports -Wno-bool-compare option. +dnl # +dnl # We actually invoke gcc with the -Wbool-compare 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_BOOL_COMPARE], [ + AC_MSG_CHECKING([whether $CC supports -Wno-bool-compare]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Wbool-compare" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ + NO_BOOL_COMPARE=-Wno-bool-compare + AC_MSG_RESULT([yes]) + ], [ + NO_BOOL_COMPARE= + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" + AC_SUBST([NO_BOOL_COMPARE]) +]) + +dnl # +dnl # Check if gcc supports -Wno-unused-but-set-variable option. +dnl # +dnl # We actually invoke gcc with the -Wunused-but-set-variable 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_UNUSED_BUT_SET_VARIABLE], [ + AC_MSG_CHECKING([whether $CC supports -Wno-unused-but-set-variable]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Wunused-but-set-variable" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ + NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable + AC_MSG_RESULT([yes]) + ], [ + NO_UNUSED_BUT_SET_VARIABLE= + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" + AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE]) +]) diff --git a/config/always-no-bool-compare.m4 b/config/always-no-bool-compare.m4 deleted file mode 100644 index 316b04b50..000000000 --- a/config/always-no-bool-compare.m4 +++ /dev/null @@ -1,27 +0,0 @@ -dnl # -dnl # Check if gcc supports -Wno-bool-compare option. -dnl # -dnl # We actually invoke gcc with the -Wbool-compare 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_NO_BOOL_COMPARE], [ - AC_MSG_CHECKING([for -Wno-bool-compare support]) - - saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wbool-compare" - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], - [ - NO_BOOL_COMPARE=-Wno-bool-compare - AC_MSG_RESULT([yes]) - ], - [ - NO_BOOL_COMPARE= - AC_MSG_RESULT([no]) - ]) - - CFLAGS="$saved_flags" - AC_SUBST([NO_BOOL_COMPARE]) -]) diff --git a/config/always-no-unused-but-set-variable.m4 b/config/always-no-unused-but-set-variable.m4 deleted file mode 100644 index 863c90a16..000000000 --- a/config/always-no-unused-but-set-variable.m4 +++ /dev/null @@ -1,27 +0,0 @@ -dnl # -dnl # Check if gcc supports -Wno-unused-but-set-variable option. -dnl # -dnl # We actually invoke gcc with the -Wunused-but-set-variable 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_NO_UNUSED_BUT_SET_VARIABLE], [ - AC_MSG_CHECKING([for -Wno-unused-but-set-variable support]) - - saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wunused-but-set-variable" - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], - [ - NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable - AC_MSG_RESULT([yes]) - ], - [ - NO_UNUSED_BUT_SET_VARIABLE= - AC_MSG_RESULT([no]) - ]) - - CFLAGS="$saved_flags" - AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index b759ccd39..f8d81cdc0 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -125,21 +125,10 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL_VM_NODE_STAT AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ - KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" + KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ" ]) - AC_SUBST(KERNELMAKE_PARAMS) - - dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other - dnl # compiler options are added by the kernel build system. - KERNELCPPFLAGS="$KERNELCPPFLAGS -std=gnu99" - KERNELCPPFLAGS="$KERNELCPPFLAGS -Wno-declaration-after-statement" - KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE" - KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_BOOL_COMPARE" - KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL" - KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" - - AC_SUBST(KERNELCPPFLAGS) + AC_SUBST(KERNEL_MAKE) ]) dnl # diff --git a/config/user-frame-larger-than.m4 b/config/user-frame-larger-than.m4 deleted file mode 100644 index e0828eca0..000000000 --- a/config/user-frame-larger-than.m4 +++ /dev/null @@ -1,22 +0,0 @@ -dnl # -dnl # Check if gcc supports -Wframe-larger-than=<size> option. -dnl # -AC_DEFUN([ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN], [ - AC_MSG_CHECKING([for -Wframe-larger-than=<size> support]) - - saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wframe-larger-than=1024" - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], - [ - FRAME_LARGER_THAN=-Wframe-larger-than=1024 - AC_MSG_RESULT([yes]) - ], - [ - FRAME_LARGER_THAN= - AC_MSG_RESULT([no]) - ]) - - CFLAGS="$saved_flags" - AC_SUBST([FRAME_LARGER_THAN]) -]) diff --git a/config/user-no-format-truncation.m4 b/config/user-no-format-truncation.m4 deleted file mode 100644 index 4426907ee..000000000 --- a/config/user-no-format-truncation.m4 +++ /dev/null @@ -1,22 +0,0 @@ -dnl # -dnl # Check if gcc supports -Wno-format-truncation option. -dnl # -AC_DEFUN([ZFS_AC_CONFIG_USER_NO_FORMAT_TRUNCATION], [ - AC_MSG_CHECKING([for -Wno-format-truncation support]) - - saved_flags="$CFLAGS" - CFLAGS="$CFLAGS -Wno-format-truncation" - - 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]) -]) diff --git a/config/user.m4 b/config/user.m4 index 73f6433a2..0bada893b 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -14,11 +14,9 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_LIBATTR ZFS_AC_CONFIG_USER_LIBUDEV ZFS_AC_CONFIG_USER_LIBSSL - ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN ZFS_AC_CONFIG_USER_RUNSTATEDIR ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV - ZFS_AC_CONFIG_USER_NO_FORMAT_TRUNCATION ZFS_AC_TEST_FRAMEWORK diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 5eaa49c87..adc99edf5 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -7,27 +7,36 @@ AC_DEFUN([ZFS_AC_LICENSE], [ ]) AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror" - HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror" - DEBUG_CFLAGS="-DDEBUG -Werror" - DEBUG_STACKFLAGS="-fstack-check" + DEBUG_CFLAGS="-Werror" + DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG" + DEBUG_LDFLAGS="" DEBUG_ZFS="_with_debug" AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled]) + + KERNEL_DEBUG_CFLAGS="-Werror" + KERNEL_DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG" ]) AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [ - KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG " - HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG " - DEBUG_CFLAGS="-DNDEBUG" - DEBUG_STACKFLAGS="" + DEBUG_CFLAGS="" + DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG" + DEBUG_LDFLAGS="" DEBUG_ZFS="_without_debug" + + KERNEL_DEBUG_CFLAGS="" + KERNEL_DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG" ]) +dnl # +dnl # When debugging is enabled: +dnl # - Enable all ASSERTs (-DDEBUG) +dnl # - Promote all compiler warnings to errors (-Werror) +dnl # AC_DEFUN([ZFS_AC_DEBUG], [ AC_MSG_CHECKING([whether assertion support will be enabled]) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], - [Enable assertion support @<:@default=no@:>@])], + [Enable compiler and code assertions @<:@default=no@:>@])], [], [enable_debug=no]) @@ -38,18 +47,28 @@ AC_DEFUN([ZFS_AC_DEBUG], [ [ZFS_AC_DEBUG_DISABLE], [AC_MSG_ERROR([Unknown option $enable_debug])]) - AC_SUBST(DEBUG_STACKFLAGS) + AC_SUBST(DEBUG_CFLAGS) + AC_SUBST(DEBUG_CPPFLAGS) + AC_SUBST(DEBUG_LDFLAGS) AC_SUBST(DEBUG_ZFS) + + AC_SUBST(KERNEL_DEBUG_CFLAGS) + AC_SUBST(KERNEL_DEBUG_CPPFLAGS) + AC_MSG_RESULT([$enable_debug]) ]) -AC_DEFUN([ZFS_AC_DEBUGINFO_KERNEL], [ - KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS CONFIG_DEBUG_INFO=y" - KERNELCPPFLAGS="${KERNELCPPFLAGS} -fno-inline" +AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [ + DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline" + + KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline" + KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y" + + DEBUGINFO_ZFS="_with_debuginfo" ]) -AC_DEFUN([ZFS_AC_DEBUGINFO_USER], [ - DEBUG_CFLAGS="${DEBUG_CFLAGS} -g -fno-inline" +AC_DEFUN([ZFS_AC_DEBUGINFO_DISABLE], [ + DEBUGINFO_ZFS="_without_debuginfo" ]) AC_DEFUN([ZFS_AC_DEBUGINFO], [ @@ -62,23 +81,26 @@ AC_DEFUN([ZFS_AC_DEBUGINFO], [ AS_CASE(["x$enable_debuginfo"], ["xyes"], - [ZFS_AC_DEBUGINFO_KERNEL - ZFS_AC_DEBUGINFO_USER], - ["xkernel"], - [ZFS_AC_DEBUGINFO_KERNEL], - ["xuser"], - [ZFS_AC_DEBUGINFO_USER], + [ZFS_AC_DEBUGINFO_ENABLE], ["xno"], - [], - [AC_MSG_ERROR([Unknown option $enable_debug])]) + [ZFS_AC_DEBUGINFO_DISABLE], + [AC_MSG_ERROR([Unknown option $enable_debuginfo])]) AC_SUBST(DEBUG_CFLAGS) + AC_SUBST(DEBUGINFO_ZFS) + + AC_SUBST(KERNEL_DEBUG_CFLAGS) + AC_SUBST(KERNEL_MAKE) + AC_MSG_RESULT([$enable_debuginfo]) ]) AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [ - ZFS_AC_CONFIG_ALWAYS_NO_UNUSED_BUT_SET_VARIABLE - ZFS_AC_CONFIG_ALWAYS_NO_BOOL_COMPARE + ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE + ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE + ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN + ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION + ZFS_AC_CONFIG_ALWAYS_CC_ASAN ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD ZFS_AC_CONFIG_ALWAYS_ARCH ]) @@ -160,9 +182,23 @@ AC_DEFUN([ZFS_AC_RPM], [ ]) RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"' - RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)" --define "_udevdir $(udevdir)" --define "_udevruledir $(udevruledir)" --define "_initconfdir $(DEFAULT_INITCONF_DIR)" $(DEFINE_INITRAMFS) $(DEFINE_SYSTEMD)' - RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)" --define "require_spldir $(SPL)" --define "require_splobj $(SPL_OBJ)" --define "ksrc $(LINUX)" --define "kobj $(LINUX_OBJ)"' - RPM_DEFINE_DKMS= + RPM_DEFINE_COMMON+=' --define "$(DEBUGINFO_ZFS) 1"' + RPM_DEFINE_COMMON+=' --define "$(ASAN_ZFS) 1"' + + RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)"' + RPM_DEFINE_UTIL+=' --define "_udevdir $(udevdir)"' + RPM_DEFINE_UTIL+=' --define "_udevruledir $(udevruledir)"' + RPM_DEFINE_UTIL+=' --define "_initconfdir $(DEFAULT_INITCONF_DIR)"' + RPM_DEFINE_UTIL+=' $(DEFINE_INITRAMFS)' + RPM_DEFINE_UTIL+=' $(DEFINE_SYSTEMD)' + + RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"' + RPM_DEFINE_KMOD+=' --define "require_spldir $(SPL)"' + RPM_DEFINE_KMOD+=' --define "require_splobj $(SPL_OBJ)"' + RPM_DEFINE_KMOD+=' --define "ksrc $(LINUX)"' + RPM_DEFINE_KMOD+=' --define "kobj $(LINUX_OBJ)"' + + RPM_DEFINE_DKMS='' SRPM_DEFINE_COMMON='--define "build_src_rpm 1"' SRPM_DEFINE_UTIL= |