libtool, java woes

Alexandre Oliva aoliva@redhat.com
Mon Apr 9 10:45:00 GMT 2001


On Apr  9, 2001, Tom Tromey <tromey@redhat.com> wrote:

>>>>>> "Alexandre" == Alexandre Oliva <aoliva@redhat.com> writes:
Alexandre> Yep.  libsupc++ is linked with -lc.  Since libsupc++
Alexandre> appears before -lpthread in the libgcj link command line,
Alexandre> -lc gets linked in first.  The solution is to move
Alexandre> -lpthread first, or get libsupc++ linked with -lpthread.
Alexandre> The former is probably best for libgcj.

> The problems I'm seeing have nothing to do with -lpthread but instead
> the relative ordering of -lc and -lgcc_s.  If -lc comes first, then my
> Java programs crash on exit.  If -lgcc_s comes first, then they work.

> For some reason libtool is deciding -lc must come first.

The problem stems from the fact that -lgcc_s appears twice in the
command line, and libtool decides the first copy can be dropped.  This
is wrong.  In the case of shared libraries, it's the last copy that
could be dropped.  In the case of static libraries, none of the copies
can be dropped, but the libtool we're using will sometimes remove one
of them; again, I think it's going to be the first one.  This is
probably a bad idea.  In the libtool mailing list, we've just had yet
another discussion about removing duplicate libraries in link
commands, and the general opinion is that discarding duplicate
libraries is fine, as long as there is a simple work-around to force
the library to be linked in multiple times.  It turns out that there
is such a work-around, and the user is free to use it.  However, in
this case, the duplicates come directly from GCC, so the user never
gets a chance to apply the work-around.  In fact, the user shouldn't
even be concerned about them.  I'll see what I can do about it.

> dependency_libs=' -L/x1/gcc3/build/i686-pc-linux-gnu/libjava -L/x1/gcc3/build/i686-pc-linux-gnu/libjava/../libstdc++-v3/libsupc++ -L/x1/gcc3/build/i686-pc-linux-gnu/libstdc++-v3/src -L/x1/gcc3/build/i686-pc-linux-gnu/libstdc++-v3/src/.libs -lm -L/x1/gcc3/build/gcc -lc -lgcc_s -lpthread -ldl  '

> I haven't yet tracked down where that -lc comes from.

It comes indirectly from a shared-library link command printed by gcc
-v.

Alexandre> What I don't understand is why libgcj is linked with
Alexandre> libsupc++, and not with libstdc++.

> We don't need or want libstdc++.

The problem is that we're duplicating some symbols.  This works on ELF
platforms, but not on AIX 4.x.  IIRC, AIX will keep separate copies of
the duplicate symbols at run-time.  Probably not a good idea.

We either need libsupc++ to be a shared library, that both libstdc++
and libgcj depend on, or have libgcj depend on libstdc++.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me



More information about the Java mailing list