Bug 56371 - When building GCC from combined tree, configure is making wrong assumptions about 'gas' and 'ld'
Summary: When building GCC from combined tree, configure is making wrong assumptions a...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-17 23:07 UTC by Karlson2k
Modified: 2014-12-30 05:53 UTC (History)
2 users (show)

See Also:
Host: i686-pc-mingw32
Target: i686-w64-mingw32, x86_64-w64-mingw32, i686-pc-mingw32
Build: i686-pc-mingw32
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Karlson2k 2013-02-17 23:07:19 UTC
When building from combined source tree, 'configure' detect binutils version and make some assumptions about gas based only on version, without making real tests.

Quotes from 'config.log' with wrong assumptions (for combined tree):

configure:21949: checking assembler for .literal16
configure:21976: result: yes
.....
configure:22101: checking assembler for .nsubspa comdat
configure:22129: result: yes
.....
configure:22274: checking linker for .hidden support
configure:22338: result: no
.....
configure:22563: checking assembler for .sleb128 and .uleb128
configure:22611: result: no
.....
configure:23630: checking assembler for thread-local storage support
configure:23657: result: yes
.....
configure:25977: checking assembler for dwarf2 debug_line support
configure:26009: result: no
.....
configure:26052: checking assembler for --gdwarf2 option
configure:26080: result: no
configure:26088: checking assembler for --gstabs option
configure:26127: result: no
.....
configure:26334: checking linker position independent executable support
configure:26353: result: no
.....
configure:26490: checking linker --as-needed support
configure:26509: result: no


Results of configure with pure GCC tree (binutils was build before GCC):

configure:21949: checking assembler for .literal16
configure:21962: /mingw/mingw32/bin/as    -o conftest.o conftest.s >&5
conftest.s: Assembler messages:
conftest.s:1: Error: unknown pseudo-op: `.literal16'
configure:21965: $? = 1
configure: failed program was
.literal16
configure:21976: result: no
.....
configure:22101: checking assembler for .nsubspa comdat
configure:22115: /mingw/mingw32/bin/as    -o conftest.o conftest.s >&5
conftest.s: Assembler messages:
conftest.s:2: Error: unknown pseudo-op: `.nsubspa'
configure:22118: $? = 1
configure: failed program was
	.SPACE $TEXT$
	.NSUBSPA $CODE$,COMDAT
configure:22129: result: no
.....
configure:22274: checking linker for .hidden support
configure:22338: result: yes
.....
configure:22563: checking assembler for .sleb128 and .uleb128
configure:22582: /mingw/mingw32/bin/as    -o conftest.o conftest.s >&5
configure:22585: $? = 0
configure:22611: result: yes
.....
configure:23630: checking assembler for thread-local storage support
configure:23643: /mingw/mingw32/bin/as   --fatal-warnings -o conftest.o conftest.s >&5
conftest.s: Assembler messages:
conftest.s:2: Error: junk at end of line, first unrecognized character is `"'
configure:23646: $? = 1
configure: failed program was

	.section ".tdata","awT",@progbits
foo:	.long	25
	.text
	movl	%gs:0, %eax
	leal	foo@tlsgd(,%ebx,1), %eax
	leal	foo@tlsldm(%ebx), %eax
	leal	foo@dtpoff(%eax), %edx
	movl	foo@gottpoff(%ebx), %eax
	subl	foo@gottpoff(%ebx), %eax
	addl	foo@gotntpoff(%ebx), %eax
	movl	foo@indntpoff, %eax
	movl	$foo@tpoff, %eax
	subl	$foo@tpoff, %eax
	leal	foo@ntpoff(%ecx), %eax
configure:23657: result: no
.....
configure:25977: checking assembler for dwarf2 debug_line support
configure:25991: /mingw/mingw32/bin/as    -o conftest.o conftest.s >&5
configure:25994: $? = 0
configure:26009: result: yes
.....
configure:26052: checking assembler for --gdwarf2 option
configure:26066: /mingw/mingw32/bin/as   --gdwarf2 -o conftest.o conftest.s >&5
configure:26069: $? = 0
configure:26080: result: yes
configure:26088: checking assembler for --gstabs option
configure:26102: /mingw/mingw32/bin/as   --gstabs -o conftest.o conftest.s >&5
configure:26105: $? = 0
configure:26112: /mingw/mingw32/bin/as --gstabs -o conftest.o conftest.s 2>&1 | grep -i warning > /dev/null
configure:26115: $? = 1
configure:26127: result: yes
.....
configure:26334: checking linker position independent executable support
configure:26353: result: yes
.....
configure:26490: checking linker --as-needed support
configure:26509: result: yes
Comment 1 Karlson2k 2013-02-17 23:12:26 UTC
Too many differences to quickly predict what and where wrong, but most significant for me is 'thread-local storage'. Compiled GCC from combined tree don't have emulation for TLS and resulted GCC fail for build any program with 'static __thread'.
Comment 2 Karlson2k 2013-02-22 15:59:56 UTC
There is bug in configure script. Just before 'checking linker for .hidden support', configure detect ld version by:

if test $in_tree_ld != yes ; then
  ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
  if echo "$ld_ver" | grep GNU > /dev/null; then
    if test x"$ld_is_gold" = xyes; then
[... cut ...]
    fi
    ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
    ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'`
    ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'`
    ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
  else
    case "${target}" in
[... cut ...]
    esac
  fi
fi

But in tree ld version is not detected at all!
Just a few lines later:

  if test $in_tree_ld = yes ; then
  gcc_cv_ld_hidden=no
  if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" -ge 13 -o "$gcc_cv_gld_major_version" -gt 2 \
     && test $in_tree_ld_is_elf = yes; then
     gcc_cv_ld_hidden=yes
  fi
else

configure make some assumption about ld basing on lv version.

As ld is build before run of gcc's configure, all detection could be unified for in-tree ld and external ld.
Comment 3 Hans-Peter Nilsson 2013-02-24 19:33:22 UTC
Related to PR54373, or at least similar.
Comment 4 Karlson2k 2013-02-25 10:53:36 UTC
Yes, it's related, but has more bugs to fix.
Comment 5 Karlson2k 2013-02-25 11:05:47 UTC
With current configure some capabilities tests for in-tree gas and ld are based only on version (that's wrong, because for COFF many features (TLS) isn't supported), other tests require version and ELF target (again wrong, because some features (dwarf2) supported of COFF too)
To workaround this, I've patched configure to make real tests on gas and ld even for combined tree as toplevel makefile build gas, ld and binutils before running gcc configure.
But for real fix we need to patch autoconfigure files.