libstdc++ libtool lossage

David Edelsohn dje@watson.ibm.com
Sat Feb 23 00:24:00 GMT 2002


	The *DEFAULT* libgcc spec for a configuration supporting shared
libraries prior to my change was:

%{shared-libgcc:-lgcc_s%M libgcc.a%s}
%{static-libgcc:libgcc.a%s libgcc_eh.a%s}
%{!shared-libgcc:%{!static-libgcc:%{shared:-lgcc_s%M}}}
%{!shared-libgcc:%{!static-libgcc:%{!shared:libgcc.a%s libgcc_eh.a%s}}}

	Please follow the logic and show me how -shared would not link
with -lgcc_s.  Remember I said DEFAULT.  Now let's look at what could
affect that...

	The reason that "gcc -shared" did not link with the shared library
on GNU/Linux is because config/linux.h defines

#if !defined(USE_GNULIBC_1) && defined(HAVE_LD_EH_FRAME_HDR)
#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
#endif

and gcc.c:init_gcc_specs defines

  p = "%{!shared-libgcc:%{!static-libgcc:%{shared:";
  obstack_grow (obstack, p, strlen (p));
#ifdef LINK_EH_SPEC
  sprintf (buffer, "%s}}}", static_name);
#else
  sprintf (buffer, "%s}}}", shared_name);
#endif

	Note very carefully what happens if LINK_EH_SPEC is defined:
static_name is used.  If LINK_EH_SPEC is not defined, shared_name is used.
LINK_EH_SPEC is causing the problem, not "gcc -shared".  LINK_EH_SPEC
affects whether "gcc -shared" links with -lgcc_s or libgcc.a.

	"gcc -shared" did not link with shared libgcc because linux.h
overrides the normal behavior.  That is the place that you and Richard
should be fixing, not CXX_FOR_TARGET and not using "gcc -shared-libgcc".

David



More information about the Java-patches mailing list