From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22069 invoked by alias); 18 Jun 2011 14:50:41 -0000 Received: (qmail 22054 invoked by uid 22791); 18 Jun 2011 14:50:40 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 18 Jun 2011 14:50:23 +0000 Received: by qwh5 with SMTP id 5so673334qwh.20 for ; Sat, 18 Jun 2011 07:50:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.17.148 with SMTP id s20mr2661676qca.149.1308408622310; Sat, 18 Jun 2011 07:50:22 -0700 (PDT) Received: by 10.229.47.78 with HTTP; Sat, 18 Jun 2011 07:50:22 -0700 (PDT) In-Reply-To: References: Date: Sat, 18 Jun 2011 15:12:00 -0000 Message-ID: Subject: Re: PING: PATCH: PR other/49325: Incorrect target HAVE_INITFINI_ARRAY check From: "H.J. Lu" To: Paolo Bonzini Cc: DJ Delorie , Alexandre Oliva , gcc-patches@gcc.gnu.org, Ralf.Wildenhues@gmx.de Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01394.txt.bz2 On Sat, Jun 18, 2011 at 6:29 AM, Paolo Bonzini wrote: > On Sat, Jun 18, 2011 at 01:24, H.J. Lu wrote: >>> Why are you not changing the gcc_AC_ macro and instead introducing >>> duplicate code? Perhaps the right solution is to add a final argument >>> to the AC_RUN_IFELSE macro (don't know, I should be on holiday and >>> hence I do not have the source code at hand :)); in any case this is >>> _not_ how you add tests that work for cross compilation. >> >> This target test needs run-time check. =A0I don't know how to properly >> check it for cross compilation and I don't feel comfortable to change >> =A0AC_RUN_IFELSE. >> >> Here is the updated patch to fix gcc_AC_INITFINI_ARRAY instead. > > Better. =A0However, the test needs to be $build =3D $target && $build =3D > $host. =A0Should be okay with that change, but please repost. > > It is also better to change the cross compilation results (the new > "else" branch and the final argument to AC_RUN_IFELSE) to "guessing > no". > > Paolo > This is the patch I checked in. Thanks. --=20 H.J. --- 2011-06-18 H.J. Lu PR other/49325 * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Properly check if .init_array can be used with .ctors on targets. * configure: Regenerated. diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index 3eec559..ff38682 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -375,13 +375,115 @@ AC_DEFUN([gcc_AC_INITFINI_ARRAY], [], [ AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support, gcc_cv_initfini_array, [dnl - AC_RUN_IFELSE([AC_LANG_SOURCE([ + if test "x${build}" =3D "x${target}" && test "x${build}" =3D "x${host}";= then + AC_RUN_IFELSE([AC_LANG_SOURCE([ +#ifdef __ia64__ +/* We turn on .preinit_array/.init_array/.fini_array support for ia64 + if it can be used. */ static int x =3D -1; int main (void) { return x; } int foo (void) { x =3D 0; } -int (*fp) (void) __attribute__ ((section (".init_array"))) =3D foo;])], +int (*fp) (void) __attribute__ ((section (".init_array"))) =3D foo; +#else +extern void abort (); +static int count; + +static void +init1005 () +{ + if (count !=3D 0) + abort (); + count =3D 1005; +} +void (*const init_array1005[]) () + __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *))= )) + =3D { init1005 }; +static void +fini1005 () +{ + if (count !=3D 1005) + abort (); +} +void (*const fini_array1005[]) () + __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *))= )) + =3D { fini1005 }; + +static void +ctor1007 () +{ + if (count !=3D 1005) + abort (); + count =3D 1007; +} +void (*const ctors1007[]) () + __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *)))) + =3D { ctor1007 }; +static void +dtor1007 () +{ + if (count !=3D 1007) + abort (); + count =3D 1005; +} +void (*const dtors1007[]) () + __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *)))) + =3D { dtor1007 }; + +static void +init65530 () +{ + if (count !=3D 1007) + abort (); + count =3D 65530; +} +void (*const init_array65530[]) () + __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *))= )) + =3D { init65530 }; +static void +fini65530 () +{ + if (count !=3D 65530) + abort (); + count =3D 1007; +} +void (*const fini_array65530[]) () + __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *))= )) + =3D { fini65530 }; + +static void +ctor65535 () +{ + if (count !=3D 65530) + abort (); + count =3D 65535; +} +void (*const ctors65535[]) () + __attribute__ ((section (".ctors"), aligned (sizeof (void *)))) + =3D { ctor65535 }; +static void +dtor65535 () +{ + if (count !=3D 65535) + abort (); + count =3D 65530; +} +void (*const dtors65535[]) () + __attribute__ ((section (".dtors"), aligned (sizeof (void *)))) + =3D { dtor65535 }; + +int +main () +{ + return 0; +} +#endif +])], [gcc_cv_initfini_array=3Dyes], [gcc_cv_initfini_array=3Dno], - [gcc_cv_initfini_array=3Dno])]) + [gcc_cv_initfini_array=3Dno]) + else + AC_MSG_CHECKING(cross compile... guessing) + gcc_cv_initfini_array=3Dno + fi]) enable_initfini_array=3D$gcc_cv_initfini_array ]) if test $enable_initfini_array =3D yes; then