bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] inline.m4: use compiler, not cpp


From: Paul Eggert
Subject: Re: [bug-gnulib] inline.m4: use compiler, not cpp
Date: Mon, 13 Nov 2006 11:46:42 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> AC_C_INLINE and gl_INLINE simply answer two different questions.

A problem I have with gl_INLINE is that it decides the value
HAVE_INLINE once, at configure-time.  If I compile most of my package
with optimization, but then recompile some modules without
optimization (for debugging), I'm stuck with the "wrong" value of
HAVE_INLINE.

How about this patch?  It defers the decision about __NO_INLINE__
until compilation.  It also makes 'configure' run a bit faster, since
there's one less compile to do.

A downside of this approach is that if I compile the xalloc module
with optimization (so that it does not bother to to generate a extern
xmalloc function, but simply assumes it's inline) but then compile an
xalloc user without optimization (so that it assumes there's an extern
xmalloc function), then the build won't link.  But that's OK with me;
I can deal with that, just as I can deal with other problems that
arise when I change CFLAGS without rerunning 'configure'.

2006-11-13  Paul Eggert  <address@hidden>

        * m4/inline.m4 (AC_C_INLINE): Don't test for __NO_INLINE__ at
        configure-time.  Instead, test for it at compile-time.

--- m4/inline.m4        10 Nov 2006 14:37:40 -0000      1.3
+++ m4/inline.m4        13 Nov 2006 19:40:49 -0000
@@ -1,4 +1,4 @@
-# inline.m4 serial 3
+# inline.m4 serial 4
 dnl Copyright (C) 2006 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,29 +12,18 @@ dnl drop unused 'static inline' function
 AC_DEFUN([gl_INLINE],
 [
   AC_REQUIRE([AC_C_INLINE])
-  AC_CACHE_CHECK([whether the compiler generally respects inline],
-    [gl_cv_c_inline_effective],
-    [if test $ac_cv_c_inline = no; then
-       gl_cv_c_inline_effective=no
-     else
-       dnl GCC defines __NO_INLINE__ if not optimizing or if -fno-inline is
-       dnl specified.
-       dnl Use AC_COMPILE_IFELSE here, not AC_EGREP_CPP, because the result
-       dnl depends on optimization flags, which can be in CFLAGS.
-       dnl (AC_EGREP_CPP looks only at the CPPFLAGS.)
-       AC_COMPILE_IFELSE(
-         [AC_LANG_PROGRAM([[]],
-           [[#ifdef __NO_INLINE__
-               #error "inline is not effective"
-             #endif]])],
-         [gl_cv_c_inline_effective=yes],
-         [gl_cv_c_inline_effective=no])
-     fi
-    ])
-  if test $gl_cv_c_inline_effective = yes; then
-    AC_DEFINE([HAVE_INLINE], 1,
-      [Define to 1 if the compiler supports one of the keywords
-       'inline', '__inline__', '__inline' and effectively inlines
-       functions marked as such.])
+AH_VERBATIM([HAVE_INLINE],
+[/* Define to 1 if the compiler supports one of the keywords
+    'inline', '__inline__', '__inline' and effectively inlines
+    functions marked as such.  */
+#ifndef __NO_INLINE__
+# undef HAVE_INLINE
+#endif])
+  if test $ac_cv_c_inline != no; then
+    cat >>confdefs.h <<_ACEOF
+#ifndef __NO_INLINE__
+# define HAVE_INLINE 1
+#endif
+_ACEOF
   fi
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]