public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Patch to not link in libgfortranbegin.a when building ftn shared libs
@ 2007-03-19 21:08 Steve Ellcey
  2007-03-19 21:34 ` Andrew Pinski
  2007-03-22 15:50 ` Steve Ellcey
  0 siblings, 2 replies; 7+ messages in thread
From: Steve Ellcey @ 2007-03-19 21:08 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: fxcoudert, paul, stevenb.gcc

This patch is to remove '-lgfortranbegin' from the link line when using
gfortran to build a shared library (gfortran -shared ...).  Since the
only symbol that gfortranbegin defines is main this should have no
effect unless the shared library built has an undef of main.  Presumably
this will not happen in general.

Background:  I am experimenting with using the newest libtool in the GCC
build.  That libtool uses gfortran to link libgfortran instead of using
the linker directly.  When it does this I get an error because it can't
find libgfortranbegin.a because it doesn't have the needed -B option to
look in the libgfortran object directory.  We could fix this by adding
the needed -B but it seems like we should not really be linking
libgfortranbegin.a into shared libraries anyway should we?

OK to checkin?  Tested on IA64 HP-UX and Linux with no problems, though
I found it odd that on Linux GCC includes crtendS.o and crtn.o in the
link line when gfortran (or gcc) with -shared to make a shared library.

Steve Ellcey
sje@cup.hp.com


2007-03-19  Steve Ellcey  <sje@cup.hp.com>

	* gfortranspec.c (lookup_option): Set use_init to 1 if -shared seen.

Index: gfortranspec.c
===================================================================
--- gfortranspec.c	(revision 123047)
+++ gfortranspec.c	(working copy)
@@ -82,6 +82,7 @@ typedef enum
 				   -nodefaultlibs.  */
   OPTION_o,			/* Aka --output.  */
   OPTION_S,			/* Aka --assemble.  */
+  OPTION_shared,		/* -shared.  */
   OPTION_syntax_only,		/* -fsyntax-only.  */
   OPTION_v,			/* Aka --verbose.  */
   OPTION_version,		/* --version.  */
@@ -174,6 +175,8 @@ lookup_option (Option *xopt, int *xskip,
 	opt = OPTION_version;
       else if (!strcmp (text, "-fversion"))	/* Really --version!! */
 	opt = OPTION_version;
+      else if (!strcmp (text, "-shared"))
+	opt = OPTION_shared;
       else if (!strcmp (text, "-Xlinker") || !strcmp (text, "-specs"))
 	skip = 1;
       else
@@ -360,6 +363,11 @@ For more information about these matters
 	     cool facility for handling --help and --verbose --help.  */
 	  return;
 
+	case OPTION_shared:
+	  /* Don't link libfortranbegin.a into shared libraries.  */
+	  use_init = 1;
+	  break;
+
 	default:
 	  break;
 	}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch to not link in libgfortranbegin.a when building ftn shared libs
  2007-03-19 21:08 Patch to not link in libgfortranbegin.a when building ftn shared libs Steve Ellcey
@ 2007-03-19 21:34 ` Andrew Pinski
  2007-03-22 15:50 ` Steve Ellcey
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Pinski @ 2007-03-19 21:34 UTC (permalink / raw)
  To: sje; +Cc: fortran, gcc-patches, fxcoudert, paul, stevenb.gcc

On 3/19/07, Steve Ellcey <sje@cup.hp.com> wrote:
> OK to checkin?  Tested on IA64 HP-UX and Linux with no problems, though
> I found it odd that on Linux GCC includes crtendS.o and crtn.o in the
> link line when gfortran (or gcc) with -shared to make a shared library.

Most likely -dynamiclib also needs to be handled, the same way for Darwin.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch to not link in libgfortranbegin.a when building ftn shared libs
  2007-03-19 21:08 Patch to not link in libgfortranbegin.a when building ftn shared libs Steve Ellcey
  2007-03-19 21:34 ` Andrew Pinski
@ 2007-03-22 15:50 ` Steve Ellcey
  2007-03-22 16:40   ` Paolo Bonzini
  1 sibling, 1 reply; 7+ messages in thread
From: Steve Ellcey @ 2007-03-22 15:50 UTC (permalink / raw)
  To: fortran, gcc-patches; +Cc: fxcoudert, paul, stevenb.gcc, pinskia

> 2007-03-19  Steve Ellcey  <sje@cup.hp.com>
> 
>       * gfortranspec.c (lookup_option): Set use_init to 1 if -shared seen.

I think I am going to drop this patch.  It doesn't fix the problem I am
trying to address anyway.  After applying this patch and fixing some
other libgfortran issues with the latest libtool I still fail to build
libgfortran because when using the fortran driver to create libgfortran
the link line winds up containing -lgfortran on it.  This fails because
we haven't built libgfortran yet, that is what we are trying to do.  I
think I need to change the libgfortran Makefile to use C or the linker
to create libgfortran instead of using the fortran driver but I haven't
figured out how to do that yet.

Steve Ellcey
sje@cup.hp.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch to not link in libgfortranbegin.a when building ftn shared  libs
  2007-03-22 15:50 ` Steve Ellcey
@ 2007-03-22 16:40   ` Paolo Bonzini
  2007-03-22 17:38     ` Steve Ellcey
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2007-03-22 16:40 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: fortran, gcc-patches, fxcoudert, paul, stevenb.gcc, pinskia

Steve Ellcey wrote:
>> 2007-03-19  Steve Ellcey  <sje@cup.hp.com>
>>
>>       * gfortranspec.c (lookup_option): Set use_init to 1 if -shared seen.
> 
> I think I am going to drop this patch.  It doesn't fix the problem I am
> trying to address anyway.  After applying this patch and fixing some
> other libgfortran issues with the latest libtool I still fail to build
> libgfortran because when using the fortran driver to create libgfortran
> the link line winds up containing -lgfortran on it.  This fails because
> we haven't built libgfortran yet, that is what we are trying to do.  I
> think I need to change the libgfortran Makefile to use C or the linker
> to create libgfortran instead of using the fortran driver but I haven't
> figured out how to do that yet.

Try writing your own rule for that, using "$(LIBTOOL) --tag=CC" instead
of the fortran tag.

Paolo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch to not link in libgfortranbegin.a when building ftn shared libs
  2007-03-22 16:40   ` Paolo Bonzini
@ 2007-03-22 17:38     ` Steve Ellcey
  2007-03-22 21:59       ` Tom Tromey
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Ellcey @ 2007-03-22 17:38 UTC (permalink / raw)
  To: bonzini; +Cc: fortran, gcc-patches, fxcoudert, paul, stevenb.gcc, pinskia

Paolo Bonzini wrote:

> Try writing your own rule for that, using "$(LIBTOOL) --tag=CC" instead
> of the fortran tag.
> 
> Paolo

I was hoping to avoid that.  In reading the automake documentation I see:

| If `library_LIBTOOLFLAGS' is not defined, the global AM_LIBTOOLFLAGS
| variable is used instead.
| 
| These flags are passed to libtool after the --tag=TAG option computed by
| Automake (if any), so `library_LIBTOOLFLAGS' (or AM_LIBTOOLFLAGS) is the
| good place to override or supplement the --tag=TAG setting.

So I am trying to set "libgfortran_LIBTOOLFLAGS = --tag=CC" in
Makefile.am but it doesn't seem to be working.  The documentation is
from automake 1.10 and I am using 1.9.6, maybe this is a new feature.

Steve Ellcey
sje@cup.hp.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch to not link in libgfortranbegin.a when building ftn shared libs
  2007-03-22 17:38     ` Steve Ellcey
@ 2007-03-22 21:59       ` Tom Tromey
  2007-03-22 22:56         ` Steve Ellcey
  0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2007-03-22 21:59 UTC (permalink / raw)
  To: Steve Ellcey
  Cc: bonzini, fortran, gcc-patches, fxcoudert, paul, stevenb.gcc, pinskia

>>>>> "Steve" == Steve Ellcey <sje@cup.hp.com> writes:

Steve> So I am trying to set "libgfortran_LIBTOOLFLAGS = --tag=CC" in
Steve> Makefile.am but it doesn't seem to be working.  The documentation is
Steve> from automake 1.10 and I am using 1.9.6, maybe this is a new feature.

Yeah, I don't see this text in the 1.9.6 manual.  In libjava we
override various LINK variables to add --tag.  This isn't supported by
Automake but we needed it to work around a bug.  I don't remember when
we added this, and I haven't looked to see whether this is still
needed.

Tom

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Patch to not link in libgfortranbegin.a when building ftn shared libs
  2007-03-22 21:59       ` Tom Tromey
@ 2007-03-22 22:56         ` Steve Ellcey
  0 siblings, 0 replies; 7+ messages in thread
From: Steve Ellcey @ 2007-03-22 22:56 UTC (permalink / raw)
  To: tromey
  Cc: bonzini, fortran, gcc-patches, fxcoudert, paul, stevenb.gcc, pinskia

Tom Tromey wrote:

> Yeah, I don't see this text in the 1.9.6 manual.  In libjava we
> override various LINK variables to add --tag.  This isn't supported by
> Automake but we needed it to work around a bug.  I don't remember when
> we added this, and I haven't looked to see whether this is still
> needed.
> 
> Tom

I think I figured it out.  See my libtool patch at:

http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01498.html

Steve Ellcey
sje@cup.hp.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-03-22 21:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-19 21:08 Patch to not link in libgfortranbegin.a when building ftn shared libs Steve Ellcey
2007-03-19 21:34 ` Andrew Pinski
2007-03-22 15:50 ` Steve Ellcey
2007-03-22 16:40   ` Paolo Bonzini
2007-03-22 17:38     ` Steve Ellcey
2007-03-22 21:59       ` Tom Tromey
2007-03-22 22:56         ` Steve Ellcey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).