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

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).