On 2014-05-01 10:10:46 -0400, Tom Lane wrote: > Andres Freund <and...@2ndquadrant.com> writes: > > I still think we really need to fix this. I have three possible > > solutions: > > > a) Add an external file (in the source tree) that's included in the > > configure test. > > b) Have a compiler specific override and specify USE_INLINE there. > > c) Drop the requirement of quiet inlines. > > > a) would probably the best, but I haven't yet found a non ugly solution :( > > Why is (a) so hard again? > > (If you're wondering where to put the file, I'd vote for the config/ > directory.)
Patch attached. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
>From 67a8595f07a93d50276f1f4dc967b33a5137ae25 Mon Sep 17 00:00:00 2001 From: Andres Freund <and...@anarazel.de> Date: Thu, 1 May 2014 20:40:31 +0200 Subject: [PATCH] Fix "quiet inline" configure test on newer clang compilers. The test used to just define a static inline function inline and check whether that causes a warning. But newer clang versions warn about unused static inline functions when defined inside a .c file, but not when defined in a included header. Change the test to cope. This caused postgres compiled with newer clang versions to not use inline functions, potentially leading to performance degradations. --- config/c-compiler.m4 | 14 ++++++++++++-- config/test_quiet_include.h | 5 +++++ configure | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 config/test_quiet_include.h diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 4ba3236..1b9a2db 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -19,7 +19,17 @@ fi])# PGAC_C_SIGNED # PGAC_C_INLINE # ------------- -# Check if the C compiler understands inline functions. +# Check if the C compiler understands inline functions without being +# noisy about unused static inline functions. Some older compilers +# understand inline functions (tested by AC_C_INLINE) but warn about +# them if they aren't used in a translation unit. +# This test used to just define a inline function, but some compilers +# (notably clang) got too smart and now warn about unused static +# inline functions when defined inside a .c file, but not when defined +# in a included header. Since the latter is what we want to use, test +# that by excluding a header defined outside autoconf's confines. Not +# pretty, but it works. +# # Defines: inline, PG_USE_INLINE AC_DEFUN([PGAC_C_INLINE], [AC_C_INLINE @@ -28,7 +38,7 @@ AC_CACHE_CHECK([for quiet inline (no complaint if unreferenced)], pgac_cv_c_inli if test "$ac_cv_c_inline" != no; then pgac_c_inline_save_werror=$ac_c_werror_flag ac_c_werror_flag=yes - AC_LINK_IFELSE([AC_LANG_PROGRAM([static inline int fun () {return 0;}],[])], + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include "$srcdir/config/test_quiet_include.h"],[])], [pgac_cv_c_inline_quietly=yes]) ac_c_werror_flag=$pgac_c_inline_save_werror fi]) diff --git a/config/test_quiet_include.h b/config/test_quiet_include.h new file mode 100644 index 0000000..d2060c1 --- /dev/null +++ b/config/test_quiet_include.h @@ -0,0 +1,5 @@ +/* + * For the raison d'etre of this file, check the comment above the definition + * of the PGAC_C_INLINE macro in config/c-compiler.m4. + */ +static inline int fun () {return 0;} diff --git a/configure b/configure index e0dbdfe..9953389 100755 --- a/configure +++ b/configure @@ -9725,7 +9725,7 @@ else ac_c_werror_flag=yes cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -static inline int fun () {return 0;} +#include "$srcdir/config/test_quiet_include.h" int main () { -- 1.8.5.rc2.dirty
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers