Certain clang compiler versions do not support -finline-functions, so only apply
this compiler option conditionally if supported.
Warnings with Apple LLVM version 8.0.0 (clang-800.0.42.1), based on upstream clang 3.9.0:
clang: warning: optimization flag '-finline-functions' is not supported
clang: warning: argument unused during compilation: '-finline-functions'
Fixes: 7dd9a7f ("Add -finline-functions to standard build flags, so gcc will
consider all functions as candidates for inlining.")
Signed-off-by: Rhys Kidd <rhyskidd@gmail.com>
# -fno-builtin is important for defeating LLVM's idiom recognition
# that somehow causes VG_(memset) to get into infinite recursion.
AM_CFLAGS_BASE = \
- -O2 -finline-functions -g \
+ -O2 -g \
-Wall \
-Wmissing-prototypes \
-Wshadow \
@FLAG_W_LOGICAL_OP@ \
@FLAG_W_ENUM_CONVERSION@ \
@FLAG_W_OLD_STYLE_DECLARATION@ \
+ @FLAG_FINLINE_FUNCTIONS@ \
@FLAG_FNO_STACK_PROTECTOR@ \
@FLAG_FSANITIZE@ \
-fno-strict-aliasing \
AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
+# does this compiler support -finline-functions ?
+AC_MSG_CHECKING([if gcc accepts -finline-functions])
+
+safe_CFLAGS=$CFLAGS
+CFLAGS="-finline-functions -Werror"
+
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
+ return 0;
+]])], [
+inline_functions=yes
+FLAG_FINLINE_FUNCTIONS="-finline-functions"
+AC_MSG_RESULT([yes])
+], [
+inline_functions=no
+FLAG_FINLINE_FUNCTIONS=""
+AC_MSG_RESULT([no])
+])
+CFLAGS=$safe_CFLAGS
+
+AC_SUBST(FLAG_FINLINE_FUNCTIONS)
+
# Does GCC support disabling Identical Code Folding?
# We want to disabled Identical Code Folding for the
# tools preload shared objects to get better backraces.