Operating System - Linux
1753850 Members
7177 Online
108807 Solutions
New Discussion юеВ

GCC libgcc will not link correctly - PERL / MYSQL

 
SOLVED
Go to solution
Eric Hagen
Occasional Advisor

GCC libgcc will not link correctly - PERL / MYSQL

Hello all,

I have been spending far too much time trying to get PERL and MYSQL to play nicely with linked 64bit libgcc objects. Does anyone know of a 64bit version of GCC that plays nicely with the latest OPENSSL, MYSQL and most importantly PERL and the libgcc functions?

At first I thought it may be generic gcc builds so I installed gcc (GCC) 4.1.2 and it works almost, but the outcome is the same as with the GCC from HP, The porting center, and Merijn. (Thanks to everyone for those great resources).

PERL compiles, but nothing I do seems to actually use the -static-libgcc flag option and move it into the Makefiles. MYSQL compiles fine and works great up until I try to compile with openssl to support PKI authentication. Then the same libgcc errors show up.

Below are the configure options IтАЩm using, I will attempt to keep this very short.

./configure --prefix=/opt/pacbin/mysql --with-low-memory --enable-thread-safe-client --without-debug \
--with-openssl=/opt/pacbin/openssl --with-openssl-includes=/opt/pacbin/include/openssl \
--enable-local-infile --with-pthread --with-lib-ccflags=-fPIC --disable-shared \
--with-extra-charsets=none --enable-assembler

/opt/pacdev/bin/ld: warning: libgcc_s.sl, needed by /opt/pacbin/lib/libpthread.sl,
not found (try using -rpath or -rpath-link)
/opt/pacdev/bin/ld: conf_to_src: hidden symbol `__divdi3' in /opt/pacbin/lib/libgcc.a(_divdi3.o) is referenced by DSO
/opt/pacdev/bin/ld: final link failed: Nonrepresentable section on output

perl-5.8.8
sh Configure -A prepend:libswanted='pthread ' -de -Dcc=gcc -DfPIC -Dcl -Dprefix=/opt/pacbin \
-Dcccdlflags='-fPIC' \
-Dlddlflags='-shared -static-libgcc -fPIC' \
-Dlddlflags='-b -L/opt/pacdev/lib -L/lib/pa20_64' \
-Dldflags='-L/opt/pacdev/lib -L/lib/pa20_64' \
-Dlibpth=='/opt/pacdev/lib /opt/pacbin/lib /lib/pa20_64 /lib /usr/lib /usr/ccs/lib'

EXAMPLE FAILED TEST.
ext/Digest/MD5/t/files..................../usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '__divdi3' in load module '../lib/auto/MIME/Base64/Base64.sl'.
ext/Unicode/Normalize/t/fcdc............../usr/lib/pa20_64/dld.sl: Unsatisfied code symbol '__umoddi3' in load module '../lib/auto/Unicode/Normalize/Normalize.sl'.
Failed 19 test scripts out of 919, 97.93% okay.
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: GCC libgcc will not link correctly - PERL / MYSQL

I believe it is telling you exactly what is wrong. The libs Base64.sl and Normalize.sl were linked incorrectly and didn't include __divdi3 and __umoddi3 when they were created:
/opt/pacdev/bin/ld: conf_to_src: hidden symbol __divdi3 in /opt/pacbin/lib/libgcc.a(_divdi3.o) is referenced by DSO

So you need to include -lgcc when building those two libs.
Eric Hagen
Occasional Advisor

Re: GCC libgcc will not link correctly - PERL / MYSQL

The problem I am running into is that even if I do say to link gcc, it still fails. The good side is I finally got MYSQL to compile with openssl support.

Directly editing Makefile to test...
If I point it to a directory without the libgcc libraries it does fail. Below is what I'm seeing.

LDDLFLAGS = -b -L/lib/pa20_64 -L/opt/pacbin/lib -lgcc
LDFLAGS = -L/lib/pa20_64 -L/opt/pacbin/lib -lgcc

rm *.o
make

gcc -c -D_HPUX_SOURCE -mpa-risc-2-0 -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -O -DVERSION=\"0.06\" -DXS_VERSION=\"0.06\" -fPIC "-I../.." byterun.c
byterun.c: In function 'byterun':
byterun.c:173: warning: comparison is always false due to limited range of data type
byterun.c:899: warning: comparison is always false due to limited range of data type
gcc -c -D_HPUX_SOURCE -mpa-risc-2-0 -DDEBUGGING -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g -O -DVERSION=\"0.06\" -DXS_VERSION=\"0.06\" -fPIC "-I../.." ByteLoader.c
Running Mkbootstrap for ByteLoader ()
chmod 644 ByteLoader.bs

rm -f ../../lib/auto/ByteLoader/ByteLoader.sl
/usr/bin/ld -b -L/lib/pa20_64 -L/opt/pacbin/lib -lgcc byterun.o ByteLoader.o -o ../../lib/auto/ByteLoader/ByteLoader.sl \
\

Warning: Some debug info sections were missing.
PXDB aborted.
chmod 755 ../../lib/auto/ByteLoader/ByteLoader.sl
cp ByteLoader.bs ../../lib/auto/ByteLoader/ByteLoader.bs
chmod 644 ../../lib/auto/ByteLoader/ByteLoader.bs

It still fails the make test.

../../lib/auto/ByteLoader/ByteLoader.sl:
64-bit ELF shared library
shared library dynamic path search:
LD_LIBRARY_PATH enabled first
SHLIB_PATH enabled second
embedded path enabled third /lib/pa20_64:/opt/pacbin/lib
shared library mapped private disabled
shared vtable support disabled
explicit unloading enabled
linkage table protection disabled
segments:
index type address flags size
5 text 4000000000000000 z---c- D (default)
6 data 8000000100000000 ---m-- D (default)
static branch prediction disabled
kernel assisted branch prediction enabled
lazy swap allocation for dynamic segments disabled
nulptr dereferences trap disabled


echo $LD_LIBRARY_PATH
/opt/pacbin/lib

ll /opt/pacbin/lib/libgcc*
-r-xr-xr-x 1 root sys 368544 Jun 28 22:30 /opt/pacbin/lib/libgcc.a
-rw-r--r-- 1 root sys 165554 Jun 28 22:30 /opt/pacbin/lib/libgcc_eh.a
-r-xr-xr-x 1 root sys 303852 Jun 27 22:32 /opt/pacbin/lib/libgcc_s.4
lrwxr-xr-x 1 root sys 10 Jun 28 22:07 /opt/pacbin/lib/libgcc_s.sl -> libgcc_s.4
-rw-r--r-- 1 root sys 4666 Jun 28 22:30 /opt/pacbin/lib/libgcc_stub.a


I know I must be missing something very basic and simple, though I am stuck.


Dennis Handly
Acclaimed Contributor
Solution

Re: GCC libgcc will not link correctly - PERL / MYSQL

I was going to say I know lots more about HP compilers than g++ but your error turns out to be pretty obvious.

>/usr/bin/ld -b -L/lib/pa20_64 -L/opt/pacbin/lib -lgcc byterun.o ByteLoader.o -o ByteLoader.sl

Libraries, especially archives must be last on the list, after objects!

The linker sees -lgcc, and thinks that's interesting and ignores it since it isn't needed yet. Then it sees the objects and when it gets to the end, there is nothing it can do.

You can either reorder your LDDLFLAGS and LDFLAGS or you can add -Wl,+n. This will cause ld to work harder and interate over the command line, until no progress.

You should also remove the default lib path:
-L/lib/pa20_64
(And this isn't correct in the first place, it should really be /usr/lib/pa20_64, since /lib is an illusion.)

>I know I must be missing something very basic and simple,

Well it was if you really look at it. ;-)
You could also see the order with "-Wl,-t".

This may be the reason there are lots of libs in the Porting Center with this same unsat problem.
Eric Hagen
Occasional Advisor

Re: GCC libgcc will not link correctly - PERL / MYSQL

Thank you, I'm a system admin guy and when it comes to the C language, well lets just say I rather use PERL.

I did have "-Wl,+n" set, but for some reason it still did not work. However, by going into the sections having this problem:
ByteLoader/
MIME/Base64/
Unicode/Normalize
Deleting the ofending *.sl and relinking it, IE:
/usr/bin/ld -b -L/opt/pacbin/lib byterun.o ByteLoader.o -lgcc -o ../../lib/auto/ByteLoader/ByteLoader.sl

Has resolved the issue. Once again thank you very much.
Eric Hagen
Occasional Advisor

Re: GCC libgcc will not link correctly - PERL / MYSQL

Manual relinking of objects failing test.
Dennis Handly
Acclaimed Contributor

Re: GCC libgcc will not link correctly - PERL / MYSQL

Another way to fix it would be to have two sets of make linker macros. The LDFLAGS you have. And another LIBS or somesuch you add to the end.