Patchwork [Revised] Fix target/PR55061

login
register
mail settings
Submitter Jack Howarth
Date Oct. 26, 2012, 2:15 p.m.
Message ID <20121026141502.GA10485@bromo.med.uc.edu>
Download mbox | patch
Permalink /patch/194489/
State New
Headers show

Comments

Jack Howarth - Oct. 26, 2012, 2:15 p.m.
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(). Rewritten to use AC_MSG_CHECKING, AC_COMPILE_IFELSE,
AC_LANG_PROGRAM and AC_MSG_RESULT instead of AC_TRY_COMPILE(). Okay for gcc trunk?
                    Jack

libbacktrace/

2012-10-26  Jack Howarth  <howarth@bromo.med.uc.edu>

	target/PR55061
	* configure.ac: Check for _Unwind_GetIPInfo function declaration.
	* configure: Regenerate.
Ian Taylor - Oct. 26, 2012, 2:41 p.m.
On Fri, Oct 26, 2012 at 7:15 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote:
>
> libbacktrace/
>
> 2012-10-26  Jack Howarth  <howarth@bromo.med.uc.edu>
>
>         target/PR55061
>         * configure.ac: Check for _Unwind_GetIPInfo function declaration.
>         * configure: Regenerate.

This is OK.

Thanks.

Ian

Patch

Index: libbacktrace/configure.ac
===================================================================
--- libbacktrace/configure.ac	(revision 192845)
+++ libbacktrace/configure.ac	(working copy)
@@ -129,8 +129,18 @@  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],
-		[have_unwind_getipinfo=no])
+  ac_save_CFFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
+  AC_MSG_CHECKING([for _Unwind_GetIPInfo])
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+       [#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"
+  AC_MSG_RESULT([$have_unwind_getipinfo])
   if test "$have_unwind_getipinfo" = "yes"; then
     AC_DEFINE(HAVE_GETIPINFO, 1, [Define if _Unwind_GetIPInfo is available.])
   fi