From 5b7e6a36175c1c13803785557b17977d2a9ecd9d Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Thu, 6 Feb 2020 12:24:37 -0500 Subject: [PATCH] Fix unknown cc flag -fno-ipa-sra Clang does not recognize -fno-ipa-sra, so add a check for it. Reviewed-by: Brian Behlendorf Reviewed-by: Prakash Surya Signed-off-by: Ryan Moeller Closes #9946 --- config/always-compiler-options.m4 | 21 +++++++++++++++++++++ config/zfs-build.m4 | 5 +++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4 index f903655fa..ca8b6bfcc 100644 --- a/config/always-compiler-options.m4 +++ b/config/always-compiler-options.m4 @@ -160,3 +160,24 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER], [ CFLAGS="$saved_flags" AC_SUBST([NO_OMIT_FRAME_POINTER]) ]) + +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]) +]) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index 5b53e9c5c..2ee9b8eb9 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -59,9 +59,9 @@ AC_DEFUN([ZFS_AC_DEBUG], [ ]) AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [ - DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline -fno-ipa-sra" + DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline $NO_IPA_SRA" - KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline -fno-ipa-sra" + KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline $NO_IPA_SRA" KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y" DEBUGINFO_ZFS="_with_debuginfo" @@ -158,6 +158,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_OMIT_FRAME_POINTER + ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA ZFS_AC_CONFIG_ALWAYS_CC_ASAN ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD ZFS_AC_CONFIG_ALWAYS_SYSTEM