Hi, .init_array is enabled only if linker can take input .ctors sections with input .init_array sections to generate the single output .init_array section in the right order so that GCC is compatible with existing .o files. Not all linkers support it even if they support .init_array section. Since I couldn't find an uniform link-time test for this feature which works for all ELF targets, run-time test is used. However, when --with-ld= is used to configure GCC, the wrong linker is used for testing. This patch checks DEFAULT_LINKER and works for me. OK for trunk?
Thanks. H.J. --- 2011-09-03 H.J. Lu <hongjiu...@intel.com> PR bootstrap/50237 * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check DEFAULT_LINKER. * configure: Regenerated. diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index d8defea..9cf0e9a 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -376,6 +376,15 @@ AC_DEFUN([gcc_AC_INITFINI_ARRAY], AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support, gcc_cv_initfini_array, [dnl if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then + saved_CC="$CC" + if test x"${DEFAULT_LINKER+set}" = x"set"; then + linker_dir="`dirname ${DEFAULT_LINKER}`" + if test x"${linker_dir+set}" = x"set"; then + if test -d ${linker_dir}; then + CC="$CC -B${linker_dir}/" + fi + fi + fi AC_RUN_IFELSE([AC_LANG_SOURCE([ #ifndef __ELF__ #error Not an ELF OS @@ -485,10 +494,11 @@ main () ])], [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no], [gcc_cv_initfini_array=no]) - else - AC_MSG_CHECKING(cross compile... guessing) - gcc_cv_initfini_array=no - fi]) + CC="$saved_CC" + else + AC_MSG_CHECKING(cross compile... guessing) + gcc_cv_initfini_array=no + fi]) enable_initfini_array=$gcc_cv_initfini_array ]) if test $enable_initfini_array = yes; then diff --git a/gcc/configure b/gcc/configure index b1dd57b..d57a7f7 100755 --- a/gcc/configure +++ b/gcc/configure @@ -10782,6 +10782,15 @@ if test "${gcc_cv_initfini_array+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then + saved_CC="$CC" + if test x"${DEFAULT_LINKER+set}" = x"set"; then + linker_dir="`dirname ${DEFAULT_LINKER}`" + if test x"${linker_dir+set}" = x"set"; then + if test -d ${linker_dir}; then + CC="$CC -B${linker_dir}/" + fi + fi + fi if test "$cross_compiling" = yes; then : gcc_cv_initfini_array=no else @@ -10904,11 +10913,12 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking cross compile... guessing" >&5 + CC="$saved_CC" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking cross compile... guessing" >&5 $as_echo_n "checking cross compile... guessing... " >&6; } - gcc_cv_initfini_array=no - fi + gcc_cv_initfini_array=no + fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_initfini_array" >&5 $as_echo "$gcc_cv_initfini_array" >&6; } @@ -17915,7 +17925,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17918 "configure" +#line 17928 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18021,7 +18031,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18024 "configure" +#line 18034 "configure" #include "confdefs.h" #if HAVE_DLFCN_H