[PATCH] Re: Serious regressions due to newlib's HAVE_INITFINI_ARRAY
Ulrich Weigand
uweigand@de.ibm.com
Thu Feb 23 12:36:00 GMT 2012
Jakub Jelinek wrote:
> On Wed, Feb 22, 2012 at 03:55:34PM +0100, Ulrich Weigand wrote:
> > However, the macro HAVE_INITFINI_ARRAY is defined anyway; this
> > definition is done by an internal "newlib.h" header that is pulled
> > in via the <stdio.h> include in GCC's "tsystem.h". [ This is clearly
> > a violation of C namespace rules, but this has been the situation
> > for all newlib releases since about 2005 ... ]
>
> Ugh, clearly newlib bug...
>
> > Any suggestions how to proceed with this welcome! I'd really
> > like to see this fixed for 4.7, otherwise the compiler will be
> > seriously broken ...
>
> I guess the easiest would be just to rename the gcc HAVE_INITFINI_ARRAY
> macro to something else, HAVE_INITFINI_ARRAY_SUPPORT or whatever.
Indeed, the following patch fixes the problem for me.
Tested on spu-elf.
OK for mainline?
Bye,
Ulrich
ChangeLog:
gcc/
* acinclude.m4: Use HAVE_INITFINI_ARRAY_SUPPORT instead of
HAVE_INITFINI_ARRAY to work around namespace pollution in
certain versions of newlib system headers.
* config.in: Regenerate.
* configure: Regenerate.
* config/initfini-array.h: Use HAVE_INITFINI_ARRAY_SUPPORT
instead of HAVE_INITFINI_ARRAY.
libgcc/
* config/ia64/crtbegin.S: Use HAVE_INITFINI_ARRAY_SUPPORT
instead of HAVE_INITFINI_ARRAY.
* config/ia64/crtend.S: Likewise.
Index: libgcc/config/ia64/crtend.S
===================================================================
*** libgcc/config/ia64/crtend.S (revision 184438)
--- libgcc/config/ia64/crtend.S (working copy)
*************** __DTOR_END__:
*** 39,48 ****
__JCR_END__:
data8 0
! #ifdef HAVE_INITFINI_ARRAY
.global __do_global_ctors_aux
.hidden __do_global_ctors_aux
! #else /* !HAVE_INITFINI_ARRAY */
/*
* Fragment of the ELF _init routine that invokes our dtor cleanup.
*
--- 39,48 ----
__JCR_END__:
data8 0
! #ifdef HAVE_INITFINI_ARRAY_SUPPORT
.global __do_global_ctors_aux
.hidden __do_global_ctors_aux
! #else /* !HAVE_INITFINI_ARRAY_SUPPORT */
/*
* Fragment of the ELF _init routine that invokes our dtor cleanup.
*
*************** __JCR_END__:
*** 71,77 ****
br.call.sptk.many b0 = b6
;;
}
! #endif /* !HAVE_INITFINI_ARRAY */
.text
.align 32
--- 71,77 ----
br.call.sptk.many b0 = b6
;;
}
! #endif /* !HAVE_INITFINI_ARRAY_SUPPORT */
.text
.align 32
Index: libgcc/config/ia64/crtbegin.S
===================================================================
*** libgcc/config/ia64/crtbegin.S (revision 184438)
--- libgcc/config/ia64/crtbegin.S (working copy)
*************** __dso_handle:
*** 61,67 ****
.hidden __dso_handle
! #ifdef HAVE_INITFINI_ARRAY
.section .fini_array, "a"
data8 @fptr(__do_global_dtors_aux)
--- 61,67 ----
.hidden __dso_handle
! #ifdef HAVE_INITFINI_ARRAY_SUPPORT
.section .fini_array, "a"
data8 @fptr(__do_global_dtors_aux)
*************** __dso_handle:
*** 70,76 ****
data8 @fptr(__do_jv_register_classes)
data8 @fptr(__do_global_ctors_aux)
! #else /* !HAVE_INITFINI_ARRAY */
/*
* Fragment of the ELF _fini routine that invokes our dtor cleanup.
*
--- 70,76 ----
data8 @fptr(__do_jv_register_classes)
data8 @fptr(__do_global_ctors_aux)
! #else /* !HAVE_INITFINI_ARRAY_SUPPORT */
/*
* Fragment of the ELF _fini routine that invokes our dtor cleanup.
*
*************** __dso_handle:
*** 117,123 ****
mov b6 = r2
br.call.sptk.many b0 = b6
}
! #endif /* !HAVE_INITFINI_ARRAY */
.section .text
.align 32
--- 117,123 ----
mov b6 = r2
br.call.sptk.many b0 = b6
}
! #endif /* !HAVE_INITFINI_ARRAY_SUPPORT */
.section .text
.align 32
Index: gcc/configure
===================================================================
*** gcc/configure (revision 184438)
--- gcc/configure (working copy)
*************** fi
*** 22515,22521 ****
if test $enable_initfini_array = yes; then
! $as_echo "#define HAVE_INITFINI_ARRAY 1" >>confdefs.h
fi
--- 22515,22521 ----
if test $enable_initfini_array = yes; then
! $as_echo "#define HAVE_INITFINI_ARRAY_SUPPORT 1" >>confdefs.h
fi
Index: gcc/config.in
===================================================================
*** gcc/config.in (revision 184438)
--- gcc/config.in (working copy)
***************
*** 1123,1129 ****
/* Define .init_array/.fini_array sections are available and working. */
#ifndef USED_FOR_TARGET
! #undef HAVE_INITFINI_ARRAY
#endif
--- 1123,1129 ----
/* Define .init_array/.fini_array sections are available and working. */
#ifndef USED_FOR_TARGET
! #undef HAVE_INITFINI_ARRAY_SUPPORT
#endif
Index: gcc/acinclude.m4
===================================================================
*** gcc/acinclude.m4 (revision 184438)
--- gcc/acinclude.m4 (working copy)
*************** changequote([,])dnl
*** 486,492 ****
enable_initfini_array=$gcc_cv_initfini_array
])
if test $enable_initfini_array = yes; then
! AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
[Define .init_array/.fini_array sections are available and working.])
fi])
--- 486,492 ----
enable_initfini_array=$gcc_cv_initfini_array
])
if test $enable_initfini_array = yes; then
! AC_DEFINE(HAVE_INITFINI_ARRAY_SUPPORT, 1,
[Define .init_array/.fini_array sections are available and working.])
fi])
Index: gcc/config/initfini-array.h
===================================================================
*** gcc/config/initfini-array.h (revision 184438)
--- gcc/config/initfini-array.h (working copy)
***************
*** 19,25 ****
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
! #ifdef HAVE_INITFINI_ARRAY
#define USE_INITFINI_ARRAY
--- 19,25 ----
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
! #ifdef HAVE_INITFINI_ARRAY_SUPPORT
#define USE_INITFINI_ARRAY
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
More information about the Gcc-patches
mailing list