]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
config: Conditionalize -finline-functions on compiler support
authorRhys Kidd <rhyskidd@gmail.com>
Sat, 2 Feb 2019 22:53:33 +0000 (17:53 -0500)
committerRhys Kidd <rhyskidd@gmail.com>
Mon, 11 Mar 2019 11:49:37 +0000 (22:49 +1100)
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>
Makefile.all.am
configure.ac

index 8ea95a611871ea9a4d2878c1cebbf530341221cf..2ad54034f0918059b6f1e6993b5f42a216f826f8 100644 (file)
@@ -97,7 +97,7 @@ clean-noinst_DSYMS:
 # -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 \
@@ -116,6 +116,7 @@ AM_CFLAGS_BASE = \
        @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 \
index d0b68b46be0261d5db845f28e1581a1266931aa9..8779cf02979102c06c85a8de8ad9c689a22f70d0 100644 (file)
@@ -2200,6 +2200,27 @@ CFLAGS=$safe_CFLAGS
 
 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.