This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++ libtool lossage
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>, Richard Henderson <rth at redhat dot com>, Mark Mitchell <mark at codesourcery dot com>
- Cc: gcc at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Sat, 23 Feb 2002 00:48:43 -0500
- Subject: Re: libstdc++ libtool lossage
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