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
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'.
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.
Related to PR54373, or at least similar.
Yes, it's related, but has more bugs to fix.
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.