Mantis - gcc4core
Viewing Issue Advanced Details
1405 regular use feature always 2006-01-19 08:46 2009-05-17 17:57
tmalik  
pfelecan  
normal  
closed  
fixed  
none    
none  
0001405: 64-bit libraries paths are not correct
When i compile with -m64 option i get following error on Solaris 2.10 whereas without -m64 option it compile works great.
ld: fatal: file /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so: wrong ELF class: ELFCLASS32

Also when i run configure with GCC4 it can\'t detect Libinconv but if I run configure with GCC3 it does detect libinconv correctly.
/opt/csw/gcc4/bin/gcc -Wall -m64 -save-temps -shared -Wl,-h -Wl,libhercs.so -o .libs/libhercs.so .libs/hsys.o -lz -lresolv -lnsl -lsocket -lm -ldl -lbz2 -lc -m64
ld: fatal: file /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so: wrong ELF class: ELFCLASS32
ld: fatal: file /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so: wrong ELF class: ELFCLASS32
Issue History
2009-05-17 17:57 mwatters Note Added: 0006126
2009-05-17 17:57 mwatters Status assigned => resolved
2009-05-17 17:57 mwatters Resolution open => fixed
2009-05-17 17:57 mwatters Note Added: 0006127
2009-05-17 17:57 mwatters Status resolved => closed

Notes
(0002987)
pfelecan   
2006-01-19 14:22   
Indeed, /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so is a 32 bit library. I wonder how it get linked in a 64 bit generation; normally, the /opt/csw/gcc4/lib/spqrcv9/libgcc_s.so is used in this case and it is a 64 bit library.

Can you give me a minimal C program which manifest this behaviour?

Please re-execute your example using the -v switch and attach the output thus obtained.

Also, I gather from your example that it is extracted from a libtool based link phase. Am I correct?
(0002989)
tmalik   
2006-01-19 21:21   
Hi,
1. I am new to unix world now.... last i did was 20 years ago....so am quite rusty.... I am trying to build a package (an IBM mainframe emulator)..... here is the link for entire source as ditsributed by the developers: http://www.hercules-390.org/hercules-3.03.1.tar.gz. [^] this will allow you to run configure and make yourself.

2. Attached is the log from Configure and make.... that i ran. http://solutionint.com/configure-and-make.log..... [^] pls also notice that it did not detect libiconv whereas gcc3 sucessfuly detects that.


Thanks for your help.
(0002990)
tmalik   
2006-01-19 21:27   
Sorry, i forgot to attach the output with -v option, here it is:

/opt/csw/gcc4/bin/gcc -Wall -v -m64 -save-temps -shared -Wl,-h -Wl,libhercs.so -o .libs/libhercs.so .libs/hsys.o -lz -lresolv -lnsl -lsocket -lm -ldl -lbz2 -lc -m64
Reading specs from /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/specs
Target: sparc-sun-solaris2.8
Configured with: ../sources/gcc-4.0.2/configure --prefix=/opt/csw/gcc4 --with-local-prefix=/opt/csw --without-gnu-as --with-as=/usr/ccs/bin/as --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-threads=posix --enable-shared --enable-multilib --enable-nls --with-included-gettext --with-libiconv-prefix=/opt/csw --with-x --enable-java-awt=xlib --with-system-zlib --enable-languages=c,c++,f95,java,objc,ada
Thread model: posix
gcc version 4.0.2
 /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.0.2/collect2 -V -G -dy -z text -R /opt/csw/gcc4/lib/sparcv9 -Y P,/opt/csw/gcc4/lib/sparcv9:/usr/lib/sparcv9 -Qy -o .libs/libhercs.so /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/sparcv9/crti.o /usr/ccs/lib/sparcv9/values-Xa.o /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/sparcv9/crtbegin.o -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/sparcv9 -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2 -L/usr/ccs/bin/sparcv9 -L/usr/ccs/bin -L/usr/ccs/lib/sparcv9 -L/usr/ccs/lib -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../sparcv9 -L/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../.. -L/lib/sparcv9 -L/usr/lib/sparcv9 -h libhercs.so .libs/hsys.o -lz -lresolv -lnsl -lsocket -lm -ldl -lbz2 -lc -lgcc_s -lgcc_s /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/sparcv9/crtend.o /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/sparcv9/crtn.o
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.482
ld: fatal: file /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so: wrong ELF class: ELFCLASS32
ld: fatal: file /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so: wrong ELF class: ELFCLASS32
ld: fatal: File processing errors. No output written to .libs/libhercs.so
collect2: ld returned 1 exit status
(0002992)
james   
2006-01-20 07:54   
See also:
http://www.blastwave.org/mantis/view_bug_page.php?f_id=0001118 [^]
(0002993)
pfelecan   
2006-01-20 10:52   
1118 is not the same case: here we have C, there we have C++. The same example as in 1118 works when on a C program. I\'m continuing the investigations.
(0002994)
tmalik   
2006-01-20 11:16   
Thanks pfelecan for your update. I really apprecaite your efforts.
(0002995)
james   
2006-01-21 05:56   
1118 is similar, it\'s just that C++ causes inclusion of -lgcc_s for a trivial program. Try:

$ echo \"main(){}\" > source.c
$ /opt/csw/gcc4/bin/gcc -m64 source.c -lgcc_s
ld: fatal: file /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.0.2/../../../libgcc_s.so: wrong ELF class: ELFCLASS32
ld: fatal: File processing errors. No output written to a.out
collect2: ld returned 1 exit status

and note the example above uses lgcc_s

ld is finding /opt/csw/gcc4/lib/libgcc_s.so.1 before /opt/csw/gcc4/lib/sparcv9/libgcc_s.so.1
(0002996)
pfelecan   
2006-01-21 16:01   
(edited on: 2006-01-21 16:02)
Using:

LD_OPTIONS=\'-Dfiles,libs,detail\' gcc -v -m64 t.c -lgcc_s -o t

and

LD_OPTIONS=\'-Dfiles,libs,detail\' g++ -v -m64 txx.cc -o txx

I found the culprit: a missing symbolic link. To link 64 bit objects you must do, as root, the following:

cd /opt/csw/gcc4/lib/sparcv9
ln -s libgcc_s.so.1 libgcc_s.so
installf CSWgcc4core /opt/csw/gcc4/lib/sparcv9/libgcc_s.so
installf -f CSWgcc4core

I\'ll put this on the package\'s main page and will correct in the package for the next release, probably 4.0.3

Note that the deep reason of this is an incorrect specification file --- /opt/csw/lib/gcc/sparc-sun-solaris2.8/4.0.2/specs --- and the correction that I\'ll made available in the future packages will use this.

edited on: 01-21 16:02
(0006126)
mwatters   
2009-05-17 17:57   
fixed in the 4.3.3 release
(0006127)
mwatters   
2009-05-17 17:57   
closed fixed