This is hurting the gnulib project: GNU ar version 2.15, used on Solaris 7 or Solaris 9, creates invalid .a files if there are no exported symbols. Test case: $ cat > hello.c #include <stdio.h> int main () { printf("Hello World\n"); return 0; } $ gcc -c hello.c $ gnu-ar --version GNU ar 2.15 Copyright 2004 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty. $ cat > dummy.c typedef int dummy; $ gcc -c dummy.c $ /bin/rm -f empty.a $ gnu-ar cru empty.a dummy.o $ /usr/ccs/bin/ld hello.o empty.a -lc -o a.out ld: fatal: file empty.a: unknown type, unable to process using elf(3E) libraries ld: fatal: File processing errors. No output written to a.out $ echo $? 1 Test case that shows that there is no problem if the system's 'ar' is used: $ cat > dummy.c typedef int dummy; $ gcc -c dummy.c $ /bin/rm -f empty.a $ /usr/ccs/bin/ar cru empty.a dummy.o $ /usr/ccs/bin/ld hello.o empty.a -lc -o a.out $ echo $? 0 Test case that shows that there is no problem if there are exported symbols: $ cat > dummy.c int dummy; $ gcc -c dummy.c $ /bin/rm -f empty.a $ gnu-ar cru empty.a dummy.o $ /usr/ccs/bin/ld hello.o empty.a -lc -o a.out $ echo $? 0
Created attachment 259 [details] Output of "gcc -c hello.c"
Created attachment 260 [details] Output of "gcc -c dummy.c"
Created attachment 261 [details] Result of "gnu-ar cru empty.a dummy.o"
Created attachment 262 [details] Result of "/usr/ccs/bin/ar cru empty.a dummy.o"
Created attachment 263 [details] Output of "gcc -c dummy.c" where dummy.c defines a global variable
Created attachment 264 [details] Result of "gnu-ar cru empty.a dummy.o" where dummy.o contains a global variable definition
sort of same thing happens on sparc-sun-solaris2.10/binutils-2.19.51.0.1 it is impossible to compile libX11-1.1.92.2 and gcc-4.3.3 using binutils-2.19.51.0.1. both tools compile fine when using binutils-2.19.50.0.1! relevant lines when compiling gcc-4.3.3 using binutils-2.19.51.0.1: === libtool: link: ar rc .libs/libmath.a stubs.o signbit.o signbitf.o signbitl.o libtool: link: ranlib .libs/libmath.a libtool: link: (cd .libs/libstdc++.lax/libmath.a && ar x /tmp/gcc-4.3.3-comp/gcc-4.3.3/sparc-sun-solaris2.10/sparcv9/libstdc++-v3/src/../libmath/.libs/libmath.a) ar: /tmp/gcc-4.3.3-comp/gcc-4.3.3/sparc-sun-solaris2.10/sparcv9/libstdc++-v3/src/../libmath/.libs/libmath.a is not a valid archive ===
Hi Niki, Please could you provide a small testcase to reproduce the problem you are having. I tried using the sequence of instructions originally described by Bruno, but they worked. I also tried a few variations of my own but I could not create a corrupt archive. Cheers Nick
Created attachment 3801 [details] ar (2.19.51.0.2.20090204) / gcc error when bootstrapping gcc-4.3.3 on i386-pc-solaris2.10
now i get the same/similar? issue with binutils-2.19.51.0.2.20090204 on i386-pc-solaris2.10. attached out2.bz2 which includes all output. i will switch to binutils-2.19.50.0.1, and i bet gcc will bootstrap okay. nick, i am not an ar/binutils specialist, just a user. maybe you can see in the output what may be the issue and tell me what i could test. i will attach /tmp/gcc-4.3.3-comp/gcc-4.3.3/i386-pc-solaris2.10/libstdc++-v3/src/../libmath/.libs/libmath.a as well. maybe you can see within that file what's wrong.
Created attachment 3802 [details] produced when bootstrapping gcc-4.3.3 on i386-pc-solaris2.10 ising binutils-2.19.51.0.2.20090204 last lines are: === /bin/bash ../libtool --tag CXX --mode=link /tmp/gcc-4.3.3-comp/gcc-4.3.3/./gcc/xgcc -shared-libgcc -B/tmp/gcc-4.3.3-comp/gcc-4.3.3/./gcc -nostdinc++ -L/tmp/gcc-4.3.3-comp/gcc-4.3.3/i386-pc-solaris2.10/libstdc++-v3/src -L/tmp/gcc-4.3.3-comp/gcc-4.3.3/i386-pc-solaris2.10/libstdc++-v3/src/.libs -B/misc/i386-pc-solaris2.10/opt/gcc/4.3.3/i386-pc-solaris2.10/bin/ -B/misc/i386-pc-solaris2.10/opt/gcc/4.3.3/i386-pc-solaris2.10/lib/ -isystem /misc/i386-pc-solaris2.10/opt/gcc/4.3.3/i386-pc-solaris2.10/include -isystem /misc/i386-pc-solaris2.10/opt/gcc/4.3.3/i386-pc-solaris2.10/sys-include -Wl,-O1 -Wl,-z,relro -Wl,--gc-sections -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -o libstdc++.la -rpath /misc/i386-pc-solaris2.10/opt/gcc/4.3.3/lib/gcc/i386-pc-solaris2.10/4.3.3 -version-info 6:10:0 -lm bitmap_allocator.lo pool_allocator.lo mt_allocator.lo codecvt.lo compatibility.lo complex_io.lo ctype.lo debug.lo functexcept.lo hash.lo hash_c++0x.lo globals_io.lo hashtable.lo hashtable_c++0x.lo ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo debug_list.lo locale.lo locale_init.lo locale_facets.lo localename.lo stdexcept.lo strstream.lo tree.lo allocator-inst.lo concept-inst.lo fstream-inst.lo ext-inst.lo ios-inst.lo iostream-inst.lo istream-inst.lo istream.lo locale-inst.lo misc-inst.lo ostream-inst.lo sstream-inst.lo streambuf-inst.lo streambuf.lo string-inst.lo valarray-inst.lo wlocale-inst.lo wstring-inst.lo atomicity.lo codecvt_members.lo collate_members.lo ctype_members.lo messages_members.lo monetary_members.lo numeric_members.lo time_members.lo basic_file.lo c++locale.lo parallel_list.lo parallel_settings.lo ../libmath/libmath.la ../libsupc++/libsupc++convenience.la -lm libtool: link: (cd .libs/libstdc++.lax/libmath.a && ar x /tmp/gcc-4.3.3-comp/gcc-4.3.3/i386-pc-solaris2.10/libstdc++-v3/src/../libmath/.libs/libmath.a) ar: /tmp/gcc-4.3.3-comp/gcc-4.3.3/i386-pc-solaris2.10/libstdc++-v3/src/../libmath/.libs/libmath.a is not a valid archive make[4]: *** [libstdc++.la] Error 1 ===
this looks interesting: === nwaibel@amdsol-1:~ $ ar t libmath.a stubs.o signbit.o signbitf.o signbitl.o nwaibel@amdsol-1:~ $ ar x libmath.a ar: libmath.a is not a valid archive nwaibel@amdsol-1:~ $ ar --version GNU ar (Linux/GNU Binutils) 2.19.51.0.2.20090204 Copyright 2008 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty. nwaibel@amdsol-1:~ $ exit logout Connection to amdsol-1 closed. nwaibel@m5000-1:~ $ ar t libmath.a stubs.o signbit.o signbitf.o signbitl.o nwaibel@m5000-1:~ $ ar x libmath.a nwaibel@m5000-1:~ $ ar --version GNU ar (Linux/GNU Binutils) 2.19.50.0.1.20081007 Copyright 2007 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty. nwaibel@m5000-1:~ $ /misc/sparc-sun-solaris2.10/opt/binutils/2.19.50.0.1/bin/ar x libmath.a nwaibel@m5000-1:~ $ /misc/sparc-sun-solaris2.10/opt/binutils/2.19.51.0.1/bin/ar --version GNU ar (Linux/GNU Binutils) 2.19.51.0.1.20090106 Copyright 2008 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) any later version. This program has absolutely no warranty. === m5000-1 is sparc-sun-solaris2.10 with binutils-2.19.50.0.1.20081007 (default) and binutils-2.19.51.0.1.20090106 amdsol-1 is i386-pc-solaris2.10 binutils-2.19.51.0.2.20090204 i am very uncertain if there is a bug when creating or when extracting the archive. or both ...
Created attachment 3803 [details] output of binutils-2.19.50.0.1.20081007 / gcc-4.3.3 bootstrap on i386-pc-solaris2.10 (okay) ... as somehow expected.
Created attachment 3804 [details] produced when bootstrapping gcc-4.3.3 on i386-pc-solaris2.10 using binutils-2.19.50.0.1.20081007 this is quite different from the prev attached libmath.a (by 2.19.51.0.2.20090204), it seems.
strange: === nwaibel@amdsol-1:~ $ /misc/i386-pc-solaris2.10/opt/binutils/2.19.51.0.2/bin/ar -x libmath.a /misc/i386-pc-solaris2.10/opt/binutils/2.19.51.0.2/bin/ar: libmath.a is not a valid archive nwaibel@amdsol-1:~ $ /misc/i386-pc-solaris2.10/opt/binutils/2.19.50.0.1/bin/ar -x libmath.a nwaibel@amdsol-1:~ $ rm -rf stubs.o signbit.o signbitf.o signbitl.o nwaibel@amdsol-1:~ $ /misc/i386-pc-solaris2.10/opt/binutils/2.19.51.0.2/bin/ar -x libmath.a-okay /misc/i386-pc-solaris2.10/opt/binutils/2.19.51.0.2/bin/ar: libmath.a-okay is not a valid archive nwaibel@amdsol-1:~ $ /misc/i386-pc-solaris2.10/opt/binutils/2.19.50.0.1/bin/ar -x libmath.a-okay ===
Hi Niki, Sorry but I still cannot reproduce the problem. I checked both versions of libmath.a that you uploaded and they both responded to the ar program, both with the 't' command and the 'x' command. If you are willing to accept a large email (~270k) I can send you a copy of the ar binary that I have been using so that you can try it out yourself. Cheers Nick
sure. just send it to my gmx addr given in Cc. i guess your version of ar will work. you may need to send me your libbfd-2.19.50.0.1.20081007.so lib also ... === $ ldd /misc/i386-pc-solaris2.10/opt/binutils/2.19.50.0.1/bin/ar libbfd-2.19.50.0.1.20081007.so => /misc/i386-pc-solaris2.10/lib/libbfd-2.19.50.0.1.20081007.so libl.so.1 => /usr/lib/libl.so.1 libz.so.1 => /misc/i386-pc-solaris2.10/lib/libz.so.1 libc.so.1 => /lib/libc.so.1 libm.so.2 => /lib/libm.so.2 ===
Hi Niki, Just one idea - have you tried building a static version of the 'ar' binary and then testing that ? Cheers Nick
okay, all my issues reported here are fixed with your patch provided in bug#9992. thanks a lot, nick! niki
reportedly fixed