On Mon, Aug 22, 2011 at 10:09 AM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Sun, Aug 21, 2011 at 10:37 PM, Jakub Jelinek <ja...@redhat.com> wrote: > nd/or add another test to it that tests >> that you can actually use >> .section .init_array >> and it will use correct section flags for the section. >> > > We need this information in config.gcc. But config.gcc is used > before assembler and readelf are detected. I am running out of > ideas. Any suggestions? > > Thanks. >
This is a much bigger change that I like and I don't feel very comfortable about it since I can only test it on Linux/x86. -- H.J. ---- 2011-08-22 H.J. Lu <hongjiu...@intel.com> * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Check if ".section .init_array" works. * configure.ac: Move binutils tests before gcc_AC_INITFINI_ARRAY. * configure: Regenerated.
diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index a8ecd2d..3827046 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -376,6 +376,18 @@ 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 + if test x$gcc_cv_as != x -a x$gcc_cv_readelf != x ; then + echo ".section .init_array; .byte 0" > conftest.s + if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then + if $gcc_cv_readelf -S --wide conftest.o 2>&1 \ + | grep INIT_ARRAY > /dev/null 2>&1; then + gcc_cv_as_init_array=yes + fi + fi + rm -f conftest.s conftest.o + fi + fi + if test "x${gcc_cv_as_init_array}" = xyes; then AC_RUN_IFELSE([AC_LANG_SOURCE([ #ifndef __ELF__ #error Not an ELF OS diff --git a/gcc/configure.ac b/gcc/configure.ac index ed01904..3cae58a 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1153,6 +1153,231 @@ fi # Restore CFLAGS from before the gcc_AC_NEED_DECLARATIONS tests. CFLAGS="$saved_CFLAGS" +# Identify the assembler which will work hand-in-glove with the newly +# built GCC, so that we can examine its features. This is the assembler +# which will be driven by the driver program. +# +# If build != host, and we aren't building gas in-tree, we identify a +# build->target assembler and hope that it will have the same features +# as the host->target assembler we'll be using. +gcc_cv_gas_major_version= +gcc_cv_gas_minor_version= +gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas + +m4_pattern_allow([AS_FOR_TARGET])dnl +AS_VAR_SET_IF(gcc_cv_as,, [ +if test -x "$DEFAULT_ASSEMBLER"; then + gcc_cv_as="$DEFAULT_ASSEMBLER" +elif test -f $gcc_cv_as_gas_srcdir/configure.in \ + && test -f ../gas/Makefile \ + && test x$build = x$host; then + gcc_cv_as=../gas/as-new$build_exeext +elif test -x as$build_exeext; then + # Build using assembler in the current directory. + gcc_cv_as=./as$build_exeext +elif ( set dummy $AS_FOR_TARGET; test -x $[2] ); then + gcc_cv_as="$AS_FOR_TARGET" +else + AC_PATH_PROG(gcc_cv_as, $AS_FOR_TARGET) +fi]) + +ORIGINAL_AS_FOR_TARGET=$gcc_cv_as +AC_SUBST(ORIGINAL_AS_FOR_TARGET) +case "$ORIGINAL_AS_FOR_TARGET" in + ./as | ./as$build_exeext) ;; + *) AC_CONFIG_FILES(as:exec-tool.in, [chmod +x as]) ;; +esac + +AC_MSG_CHECKING(what assembler to use) +if test "$gcc_cv_as" = ../gas/as-new$build_exeext; then + # Single tree build which includes gas. We want to prefer it + # over whatever linker top-level may have detected, since + # we'll use what we're building after installation anyway. + AC_MSG_RESULT(newly built gas) + in_tree_gas=yes + _gcc_COMPUTE_GAS_VERSION + in_tree_gas_is_elf=no + if grep 'obj_format = elf' ../gas/Makefile > /dev/null \ + || (grep 'obj_format = multi' ../gas/Makefile \ + && grep 'extra_objects =.* obj-elf' ../gas/Makefile) > /dev/null + then + in_tree_gas_is_elf=yes + fi +else + AC_MSG_RESULT($gcc_cv_as) + in_tree_gas=no +fi + +# Identify the linker which will work hand-in-glove with the newly +# built GCC, so that we can examine its features. This is the linker +# which will be driven by the driver program. +# +# If build != host, and we aren't building gas in-tree, we identify a +# build->target linker and hope that it will have the same features +# as the host->target linker we'll be using. +gcc_cv_gld_major_version= +gcc_cv_gld_minor_version= +gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld +gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd + +AS_VAR_SET_IF(gcc_cv_ld,, [ +if test -x "$DEFAULT_LINKER"; then + gcc_cv_ld="$DEFAULT_LINKER" +elif test -f $gcc_cv_ld_gld_srcdir/configure.in \ + && test -f ../ld/Makefile \ + && test x$build = x$host; then + gcc_cv_ld=../ld/ld-new$build_exeext +elif test -x collect-ld$build_exeext; then + # Build using linker in the current directory. + gcc_cv_ld=./collect-ld$build_exeext +elif ( set dummy $LD_FOR_TARGET; test -x $[2] ); then + gcc_cv_ld="$LD_FOR_TARGET" +else + AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET) +fi]) + +ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld +PLUGIN_LD=`basename $gcc_cv_ld` +AC_ARG_WITH(plugin-ld, +[AS_HELP_STRING([[--with-plugin-ld=[ARG]]], [specify the plugin linker])], +[if test x"$withval" != x; then + ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval" + PLUGIN_LD="$withval" + fi]) +AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET) +AC_DEFINE_UNQUOTED(PLUGIN_LD, "$PLUGIN_LD", [Specify plugin linker]) + +# Check to see if we are using gold instead of ld +AC_MSG_CHECKING(whether we are using gold) +ld_is_gold=no +if test x$gcc_cv_ld != x; then + if $gcc_cv_ld --version 2>/dev/null | sed 1q \ + | grep "GNU gold" > /dev/null; then + ld_is_gold=yes + fi +fi +AC_MSG_RESULT($ld_is_gold) + +ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld +AC_SUBST(ORIGINAL_LD_FOR_TARGET) +case "$ORIGINAL_LD_FOR_TARGET" in + ./collect-ld | ./collect-ld$build_exeext) ;; + *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;; +esac + +AC_MSG_CHECKING(what linker to use) +if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext \ + || test "$gcc_cv_ld" = ../gold/ld-new$build_exeext; then + # Single tree build which includes ld. We want to prefer it + # over whatever linker top-level may have detected, since + # we'll use what we're building after installation anyway. + AC_MSG_RESULT(newly built ld) + in_tree_ld=yes + in_tree_ld_is_elf=no + if (grep 'EMUL = .*elf' ../ld/Makefile \ + || grep 'EMUL = .*linux' ../ld/Makefile \ + || grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then + in_tree_ld_is_elf=yes + elif test "$ld_is_gold" = yes; then + in_tree_ld_is_elf=yes + fi + for f in $gcc_cv_ld_bfd_srcdir/configure $gcc_cv_ld_gld_srcdir/configure $gcc_cv_ld_gld_srcdir/configure.in $gcc_cv_ld_gld_srcdir/Makefile.in + do +changequote(,)dnl + gcc_cv_gld_version=`sed -n -e 's/^[ ]*\(VERSION=[0-9]*\.[0-9]*.*\)/\1/p' < $f` + if test x$gcc_cv_gld_version != x; then + break + fi + done + gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"` + gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"` +changequote([,])dnl +else + AC_MSG_RESULT($gcc_cv_ld) + in_tree_ld=no +fi + +# Figure out what nm we will be using. +gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils +AS_VAR_SET_IF(gcc_cv_nm,, [ +if test -f $gcc_cv_binutils_srcdir/configure.in \ + && test -f ../binutils/Makefile \ + && test x$build = x$host; then + gcc_cv_nm=../binutils/nm-new$build_exeext +elif test -x nm$build_exeext; then + gcc_cv_nm=./nm$build_exeext +elif ( set dummy $NM_FOR_TARGET; test -x $[2] ); then + gcc_cv_nm="$NM_FOR_TARGET" +else + AC_PATH_PROG(gcc_cv_nm, $NM_FOR_TARGET) +fi]) + +AC_MSG_CHECKING(what nm to use) +if test "$gcc_cv_nm" = ../binutils/nm-new$build_exeext; then + # Single tree build which includes binutils. + AC_MSG_RESULT(newly built nm) + in_tree_nm=yes +else + AC_MSG_RESULT($gcc_cv_nm) + in_tree_nm=no +fi + +ORIGINAL_NM_FOR_TARGET=$gcc_cv_nm +AC_SUBST(ORIGINAL_NM_FOR_TARGET) +case "$ORIGINAL_NM_FOR_TARGET" in + ./nm | ./nm$build_exeext) ;; + *) AC_CONFIG_FILES(nm:exec-tool.in, [chmod +x nm]) ;; +esac + + +# Figure out what objdump we will be using. +AS_VAR_SET_IF(gcc_cv_objdump,, [ +if test -f $gcc_cv_binutils_srcdir/configure.in \ + && test -f ../binutils/Makefile \ + && test x$build = x$host; then + # Single tree build which includes binutils. + gcc_cv_objdump=../binutils/objdump$build_exeext +elif test -x objdump$build_exeext; then + gcc_cv_objdump=./objdump$build_exeext +elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then + gcc_cv_objdump="$OBJDUMP_FOR_TARGET" +else + AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET) +fi]) + +AC_MSG_CHECKING(what objdump to use) +if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then + # Single tree build which includes binutils. + AC_MSG_RESULT(newly built objdump) +elif test x$gcc_cv_objdump = x; then + AC_MSG_RESULT(not found) +else + AC_MSG_RESULT($gcc_cv_objdump) +fi + +# Figure out what readelf we will be using. +AS_VAR_SET_IF(gcc_cv_readelf,, [ +if test -f $gcc_cv_binutils_srcdir/configure.in \ + && test -f ../binutils/Makefile \ + && test x$build = x$host; then + # Single tree build which includes binutils. + gcc_cv_readelf=../binutils/readelf$build_exeext +elif test -x readelf$build_exeext; then + gcc_cv_readelf=./readelf$build_exeext +else + AC_PATH_PROG(gcc_cv_readelf, readelf) +fi]) + +AC_MSG_CHECKING(what readelf to use) +if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then + # Single tree build which includes binutils. + AC_MSG_RESULT(newly built readelf) +elif test x$gcc_cv_readelf = x; then + AC_MSG_RESULT(not found) +else + AC_MSG_RESULT($gcc_cv_readelf) +fi + gcc_AC_INITFINI_ARRAY # mkdir takes a single argument on some systems. @@ -1892,231 +2117,6 @@ AC_PROG_LIBTOOL AC_SUBST(objdir) AC_SUBST(enable_fast_install) -# Identify the assembler which will work hand-in-glove with the newly -# built GCC, so that we can examine its features. This is the assembler -# which will be driven by the driver program. -# -# If build != host, and we aren't building gas in-tree, we identify a -# build->target assembler and hope that it will have the same features -# as the host->target assembler we'll be using. -gcc_cv_gas_major_version= -gcc_cv_gas_minor_version= -gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/gas - -m4_pattern_allow([AS_FOR_TARGET])dnl -AS_VAR_SET_IF(gcc_cv_as,, [ -if test -x "$DEFAULT_ASSEMBLER"; then - gcc_cv_as="$DEFAULT_ASSEMBLER" -elif test -f $gcc_cv_as_gas_srcdir/configure.in \ - && test -f ../gas/Makefile \ - && test x$build = x$host; then - gcc_cv_as=../gas/as-new$build_exeext -elif test -x as$build_exeext; then - # Build using assembler in the current directory. - gcc_cv_as=./as$build_exeext -elif ( set dummy $AS_FOR_TARGET; test -x $[2] ); then - gcc_cv_as="$AS_FOR_TARGET" -else - AC_PATH_PROG(gcc_cv_as, $AS_FOR_TARGET) -fi]) - -ORIGINAL_AS_FOR_TARGET=$gcc_cv_as -AC_SUBST(ORIGINAL_AS_FOR_TARGET) -case "$ORIGINAL_AS_FOR_TARGET" in - ./as | ./as$build_exeext) ;; - *) AC_CONFIG_FILES(as:exec-tool.in, [chmod +x as]) ;; -esac - -AC_MSG_CHECKING(what assembler to use) -if test "$gcc_cv_as" = ../gas/as-new$build_exeext; then - # Single tree build which includes gas. We want to prefer it - # over whatever linker top-level may have detected, since - # we'll use what we're building after installation anyway. - AC_MSG_RESULT(newly built gas) - in_tree_gas=yes - _gcc_COMPUTE_GAS_VERSION - in_tree_gas_is_elf=no - if grep 'obj_format = elf' ../gas/Makefile > /dev/null \ - || (grep 'obj_format = multi' ../gas/Makefile \ - && grep 'extra_objects =.* obj-elf' ../gas/Makefile) > /dev/null - then - in_tree_gas_is_elf=yes - fi -else - AC_MSG_RESULT($gcc_cv_as) - in_tree_gas=no -fi - -# Identify the linker which will work hand-in-glove with the newly -# built GCC, so that we can examine its features. This is the linker -# which will be driven by the driver program. -# -# If build != host, and we aren't building gas in-tree, we identify a -# build->target linker and hope that it will have the same features -# as the host->target linker we'll be using. -gcc_cv_gld_major_version= -gcc_cv_gld_minor_version= -gcc_cv_ld_gld_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/ld -gcc_cv_ld_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd - -AS_VAR_SET_IF(gcc_cv_ld,, [ -if test -x "$DEFAULT_LINKER"; then - gcc_cv_ld="$DEFAULT_LINKER" -elif test -f $gcc_cv_ld_gld_srcdir/configure.in \ - && test -f ../ld/Makefile \ - && test x$build = x$host; then - gcc_cv_ld=../ld/ld-new$build_exeext -elif test -x collect-ld$build_exeext; then - # Build using linker in the current directory. - gcc_cv_ld=./collect-ld$build_exeext -elif ( set dummy $LD_FOR_TARGET; test -x $[2] ); then - gcc_cv_ld="$LD_FOR_TARGET" -else - AC_PATH_PROG(gcc_cv_ld, $LD_FOR_TARGET) -fi]) - -ORIGINAL_PLUGIN_LD_FOR_TARGET=$gcc_cv_ld -PLUGIN_LD=`basename $gcc_cv_ld` -AC_ARG_WITH(plugin-ld, -[AS_HELP_STRING([[--with-plugin-ld=[ARG]]], [specify the plugin linker])], -[if test x"$withval" != x; then - ORIGINAL_PLUGIN_LD_FOR_TARGET="$withval" - PLUGIN_LD="$withval" - fi]) -AC_SUBST(ORIGINAL_PLUGIN_LD_FOR_TARGET) -AC_DEFINE_UNQUOTED(PLUGIN_LD, "$PLUGIN_LD", [Specify plugin linker]) - -# Check to see if we are using gold instead of ld -AC_MSG_CHECKING(whether we are using gold) -ld_is_gold=no -if test x$gcc_cv_ld != x; then - if $gcc_cv_ld --version 2>/dev/null | sed 1q \ - | grep "GNU gold" > /dev/null; then - ld_is_gold=yes - fi -fi -AC_MSG_RESULT($ld_is_gold) - -ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld -AC_SUBST(ORIGINAL_LD_FOR_TARGET) -case "$ORIGINAL_LD_FOR_TARGET" in - ./collect-ld | ./collect-ld$build_exeext) ;; - *) AC_CONFIG_FILES(collect-ld:exec-tool.in, [chmod +x collect-ld]) ;; -esac - -AC_MSG_CHECKING(what linker to use) -if test "$gcc_cv_ld" = ../ld/ld-new$build_exeext \ - || test "$gcc_cv_ld" = ../gold/ld-new$build_exeext; then - # Single tree build which includes ld. We want to prefer it - # over whatever linker top-level may have detected, since - # we'll use what we're building after installation anyway. - AC_MSG_RESULT(newly built ld) - in_tree_ld=yes - in_tree_ld_is_elf=no - if (grep 'EMUL = .*elf' ../ld/Makefile \ - || grep 'EMUL = .*linux' ../ld/Makefile \ - || grep 'EMUL = .*lynx' ../ld/Makefile) > /dev/null; then - in_tree_ld_is_elf=yes - elif test "$ld_is_gold" = yes; then - in_tree_ld_is_elf=yes - fi - for f in $gcc_cv_ld_bfd_srcdir/configure $gcc_cv_ld_gld_srcdir/configure $gcc_cv_ld_gld_srcdir/configure.in $gcc_cv_ld_gld_srcdir/Makefile.in - do -changequote(,)dnl - gcc_cv_gld_version=`sed -n -e 's/^[ ]*\(VERSION=[0-9]*\.[0-9]*.*\)/\1/p' < $f` - if test x$gcc_cv_gld_version != x; then - break - fi - done - gcc_cv_gld_major_version=`expr "$gcc_cv_gld_version" : "VERSION=\([0-9]*\)"` - gcc_cv_gld_minor_version=`expr "$gcc_cv_gld_version" : "VERSION=[0-9]*\.\([0-9]*\)"` -changequote([,])dnl -else - AC_MSG_RESULT($gcc_cv_ld) - in_tree_ld=no -fi - -# Figure out what nm we will be using. -gcc_cv_binutils_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/binutils -AS_VAR_SET_IF(gcc_cv_nm,, [ -if test -f $gcc_cv_binutils_srcdir/configure.in \ - && test -f ../binutils/Makefile \ - && test x$build = x$host; then - gcc_cv_nm=../binutils/nm-new$build_exeext -elif test -x nm$build_exeext; then - gcc_cv_nm=./nm$build_exeext -elif ( set dummy $NM_FOR_TARGET; test -x $[2] ); then - gcc_cv_nm="$NM_FOR_TARGET" -else - AC_PATH_PROG(gcc_cv_nm, $NM_FOR_TARGET) -fi]) - -AC_MSG_CHECKING(what nm to use) -if test "$gcc_cv_nm" = ../binutils/nm-new$build_exeext; then - # Single tree build which includes binutils. - AC_MSG_RESULT(newly built nm) - in_tree_nm=yes -else - AC_MSG_RESULT($gcc_cv_nm) - in_tree_nm=no -fi - -ORIGINAL_NM_FOR_TARGET=$gcc_cv_nm -AC_SUBST(ORIGINAL_NM_FOR_TARGET) -case "$ORIGINAL_NM_FOR_TARGET" in - ./nm | ./nm$build_exeext) ;; - *) AC_CONFIG_FILES(nm:exec-tool.in, [chmod +x nm]) ;; -esac - - -# Figure out what objdump we will be using. -AS_VAR_SET_IF(gcc_cv_objdump,, [ -if test -f $gcc_cv_binutils_srcdir/configure.in \ - && test -f ../binutils/Makefile \ - && test x$build = x$host; then - # Single tree build which includes binutils. - gcc_cv_objdump=../binutils/objdump$build_exeext -elif test -x objdump$build_exeext; then - gcc_cv_objdump=./objdump$build_exeext -elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then - gcc_cv_objdump="$OBJDUMP_FOR_TARGET" -else - AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET) -fi]) - -AC_MSG_CHECKING(what objdump to use) -if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then - # Single tree build which includes binutils. - AC_MSG_RESULT(newly built objdump) -elif test x$gcc_cv_objdump = x; then - AC_MSG_RESULT(not found) -else - AC_MSG_RESULT($gcc_cv_objdump) -fi - -# Figure out what readelf we will be using. -AS_VAR_SET_IF(gcc_cv_readelf,, [ -if test -f $gcc_cv_binutils_srcdir/configure.in \ - && test -f ../binutils/Makefile \ - && test x$build = x$host; then - # Single tree build which includes binutils. - gcc_cv_readelf=../binutils/readelf$build_exeext -elif test -x readelf$build_exeext; then - gcc_cv_readelf=./readelf$build_exeext -else - AC_PATH_PROG(gcc_cv_readelf, readelf) -fi]) - -AC_MSG_CHECKING(what readelf to use) -if test "$gcc_cv_readelf" = ../binutils/readelf$build_exeext; then - # Single tree build which includes binutils. - AC_MSG_RESULT(newly built readelf) -elif test x$gcc_cv_readelf = x; then - AC_MSG_RESULT(not found) -else - AC_MSG_RESULT($gcc_cv_readelf) -fi - # Figure out what assembler alignment features are present. gcc_GAS_CHECK_FEATURE([.balign and .p2align], gcc_cv_as_balign_and_p2align, [2,6,0],,