This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix linking C executables/shared libraries which use __attribute__((cleanup ()))


On Wed, Apr 14, 2004 at 10:23:41PM +0100, Richard Sandiford wrote:
> > 2004-03-27  Alan Modra  <amodra@bigpond.net.au>
> > 	    Jakub Jelinek  <jakub@redhat.com>
> >
> > 	* gcc.c (init_gcc_specs): If HAVE_LD_AS_NEEDED, link with
> > 	-lgcc --as-needed -lgcc_s --no-as-needed by default.
> > 	* configure.ac (HAVE_LD_AS_NEEDED): Check for ld --as-needed.
> > 	* configure: Rebuilt.
> > 	* config.in: Rebuilt.
> 
> This patch causes some bootstrap problems for mips-sgi-irix6.5 if using
> a prebuilt 2.15 binutils.  I hesitate to say it's "broken" bootstrap,
> but every program built by the stage1 compiler now depends on libgcc_s.so,
> so it's necessary to set up LD_LIBRARY*_PATHs for the gcc build directory
> before starting the build.  I gather that this isn't necessary for
> *-linux-gnu targets.
> 
> As far as I can tell, libgcc_s is always treated as needed, since it
> resolves undefined weak symbols in crtbegin.o (__register_frame_info,
> __deregister_frame_info and _Jv_RegisterClasses).  Every C program,
> even "int main () { return 0; }", will therefore require libgcc_s.so.

Certainly not _Jv_RegisterClasses, as that is only satisfied by libgcj.
__{,de}register_frame_info shouldn't be used when using even far older
binutils than those which support --as-needed if using glibc.

So probably the #if conditional in init_gcc_specs needs to be
#if defined HAVE_LD_AS_NEEDED && test_whether_USE_EH_FRAME_REGISTRY_will_not_be_defined
The question is how to find that out, since in crtstuff.c it uses target
headers to find that out, but we don't have such luxury in gcc.c.
Ideas?

Using AC_CACHE_CHECK is surely a good thing, though I have no rights to
approve it.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]