Currently gcc trunk fails to bootstrap on powerpc-apple-darwin9, using the 
default
system compiler, in libbacktrace due to the absence of _Unwind_GetIPInfo() in 
the
unwind.h header of Apple gcc 4.0.1 compiler. The attached patch eliminates this
failure by enhancing the configure.ac test for the _Unwind_GetIPInfo() function 
to
also test for its function declaration using 
-Werror-implicit-function-declaration.
This change allows HAVE_GETIPINFO to remain properly undefined in stage 1 when
using the gcc 4.0.1 compiler but not in later stages with the built compiler.
It also properly leaves HAVE_GETIPINFO undefined when using the clang compiler
from Xcode 4.2 which lacks an unwind.h header but defines it for clang from
Xcode 4.5.1 which does. Also tested on x86_64 Fedora 15 without regression in
detection of _Unwind_GetIPInfo(). Okay for gcc trunk?
                    Jack

libbacktrace/

2012-10-25  Jack Howarth  <howa...@bromo.med.uc.edu>

        target/PR55061
        * configure.ac: Check for _Unwind_GetIPInfo function declaration.
        * configure: Regenerate.

Index: libbacktrace/configure.ac
===================================================================
--- libbacktrace/configure.ac   (revision 192824)
+++ libbacktrace/configure.ac   (working copy)
@@ -129,8 +129,15 @@ AC_SUBST(WARN_FLAGS)
 if test -n "${with_target_subdir}"; then
   GCC_CHECK_UNWIND_GETIPINFO
 else
-  AC_CHECK_FUNC(_Unwind_GetIPInfo, [have_unwind_getipinfo=yes],
+  ac_save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
+  AC_TRY_COMPILE([#include "unwind.h"], [
+                    struct _Unwind_Context *context;
+                    int ip_before_insn = 0;
+                    return _Unwind_GetIPInfo (context, &ip_before_insn);
+                  ], [have_unwind_getipinfo=yes],
                [have_unwind_getipinfo=no])
+  CFLAGS="$ac_save_CFLAGS"
   if test "$have_unwind_getipinfo" = "yes"; then
     AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
   fi

Reply via email to