While working on bug 648, I tracked down the problem of the pcre test
failure to the fact that libtool was incorrectly building shared
libraries with open64.  Specifically, it would put crtbeginS.o at
the end of the link line when creating a shared library instead of
at the beginning.  When I changed this by hand then the test suite
passed.

I tracked down the crtbeginS.o problem down to how libtool creates
the link line used to create shared libraries and before I propose
a patch to the libtool maintainers I thought I would run it by
the open64 developers.

libtool runs:

$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"

To see what the link looks like and then it parses the output of this
command to create a list of flags and objects to put before the list of
objects being linked into a shared libraries and a list of flags and
objects to put after the list of objects.

Now if you run the above command with CC=g++, you get one line of output,
something like:

/usr/lib64/gcc/x86_64-suse-linux/4.1.2/collect2 --eh-frame-hdr -m elf_x86_64 
-shared /usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crti.o 
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtbeginS.o 
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2 
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64 -L/lib/../lib64 
-L/usr/lib/../lib64 
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../x86_64-suse-linux/lib 
-L/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../.. conftest.o -lstdc++ -lm 
-lgcc_s -lc -lgcc_s /usr/lib64/gcc/x86_64-suse-linux/4.1.2/crtendS.o 
/usr/lib64/gcc/x86_64-suse-linux/4.1.2/../../../../lib64/crtn.o

and everything works fine.  libtool looks at what comes before and after
conftest.o and builds is arguments.

If you run this command with openCC you get two lines of output,
something like this:

/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/bin/g++ -demangle -shared -v 
-L/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2/64 
-Wl,-rpath,/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2/64
 
-Wl,-rpath-link,/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2/64
 -L/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2 
-Wl,-rpath,/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2 
-Wl,-rpath-link,/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2
 conftest.o -lopen64rt_shared -lacml_mv -lm -lmv -lm
/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/libexec/gcc/x86_64-redhat-linux/4.2.0/collect2
 --eh-frame-hdr -m elf_x86_64 -shared /usr/lib/../lib64/crti.o 
/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/lib/gcc/x86_64-redhat-linux/4.2.0/crtbeginS.o
 -L/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2/64 
-L/wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2 
-L/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/lib/gcc/x86_64-redhat-linux/4.2.0
 
-L/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/lib/gcc/x86_64-redhat-linux/4.2.0/../../../../lib64
 -L/lib/../lib64 -L/usr/lib/../lib64 
-L/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/lib/gcc/x86_64-redhat-linux/4.2.0/../../..
 -rpath /wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2/64 
-rpath /wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2 
-rpath-link /wsp/sje/open64-net2/bits-x86//lib/gcc-lib/x86_64-open64-linux/4.2 
conftest.o -lopen64rt_shared -lacml_mv -lmv -lm -lstdc++ -
 lm -lgcc_s -lc -lgcc_s 
/wsp/sje/open64-net2/bits-x86/open64-gcc-4.2.0/lib/gcc/x86_64-redhat-linux/4.2.0/crtendS.o
 /usr/lib/../lib64/crtn.o

And things don't work right because we have two lines of output and
conftest.o appears in both of them.

Now, if we modify libtool to ignore the first line of this output, then
everything will work fine and crtbeginS.o gets put at the beginning of
the link line creating the shared library like it should.  Before
sending a patch to libtool I thought I would see what people think the
best way is to filter out the first line.  My thought was to search for
'crt' or 'collect2' and use that to get just the third line.  So we
would change:

$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"

to

$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "crt"

This change would go in libltdl/m4/libtool.m4 of libtool and it would
take a while to propagate into packages that use libtool but I don't
think we could fix this in open64 unless we changed the output of
'openCC -v'.  There are already changes/hacks like this in libtool
for other compilers like KAI, Intel, HP, etc.  You can find them by
looking for various settings of the variable output_verbose_link_cmd.

What do folks think?

Steve Ellcey
s...@cup.hp.com

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to