Re: New option: -fstatic-libgfortran

2007-04-24 Thread H. J. Lu
On Tue, Apr 24, 2007 at 10:55:56AM +0200, François-Xavier Coudert wrote:
> >Sorry about the (possibly off) question: would this apply also to
> >GMP/MPFR, if not, wouldn't it make sense?
> 
> GMP and MPFR are host libraries, so it is actually an independent
> issue. However, it might be worth having --with-static-gmp and
> --with-static-mpfr to request static linking of these libraries into
> the compiler. I think I suggested the idea (maybe even a patch, but I
> can't find it in the mailing-list archives) when gmp/mpfr was still
> only used by Fortran.
> 
> In the end, some people will think it's stretching the configury too
> much for a specific purpose, and some people will think it's just a
> good option to have. (I'm in the second group.) Let's wait and see
> what people think of the idea.

I just keep this local patch.


H.J.

--- gcc/Makefile.in.gmp 2006-05-19 06:23:09.0 -0700
+++ gcc/Makefile.in 2006-05-19 13:20:17.0 -0700
@@ -295,7 +295,7 @@ ZLIB = @zlibdir@ -lz
 ZLIBINC = @zlibinc@
 
 # How to find GMP
-GMPLIBS = @GMPLIBS@
+GMPLIBS = -Wl,-Bstatic @GMPLIBS@ -Wl,-Bdynamic
 GMPINC = @GMPINC@
 
 CPPLIB = ../libcpp/libcpp.a


Re: New option: -fstatic-libgfortran

2007-04-24 Thread François-Xavier Coudert

Sorry about the (possibly off) question: would this apply also to
GMP/MPFR, if not, wouldn't it make sense?


GMP and MPFR are host libraries, so it is actually an independent
issue. However, it might be worth having --with-static-gmp and
--with-static-mpfr to request static linking of these libraries into
the compiler. I think I suggested the idea (maybe even a patch, but I
can't find it in the mailing-list archives) when gmp/mpfr was still
only used by Fortran.

In the end, some people will think it's stretching the configury too
much for a specific purpose, and some people will think it's just a
good option to have. (I'm in the second group.) Let's wait and see
what people think of the idea.

FX


Re: New option: -fstatic-libgfortran

2007-04-24 Thread Philippe Schaffnit

Oops! Thanks a lot for your reply.

Philippe

Brooks Moses wrote:
> 
> Philippe Schaffnit wrote:
> > Sorry about the (possibly off) question: would this apply also to
> > GMP/MPFR, if not, wouldn't it make sense?
> 
> It wouldn't make sense -- GMP and MPFR are never linked into the
> compiled output at all.  (They're only used within the compiler itself,
> for processing constant values and suchlike, and then the results from
> that are put in the compiled file.)
> 
> - Brooks



Re: New option: -fstatic-libgfortran

2007-04-24 Thread Brooks Moses

Philippe Schaffnit wrote:

Sorry about the (possibly off) question: would this apply also to
GMP/MPFR, if not, wouldn't it make sense?


It wouldn't make sense -- GMP and MPFR are never linked into the 
compiled output at all.  (They're only used within the compiler itself, 
for processing constant values and suchlike, and then the results from 
that are put in the compiled file.)


- Brooks



Re: New option: -fstatic-libgfortran

2007-04-23 Thread Philippe Schaffnit

Hi!

Sorry about the (possibly off) question: would this apply also to
GMP/MPFR, if not, wouldn't it make sense?

Philippe

François-Xavier Coudert wrote:
> 
> Hi all,
> 
> Attached is a first draft of a patch to add a -fstatic-libgfortran
> option. This new option is recognized by the driver and instead of
> adding "-lgfortran" to the various subprocesses, it adds "-Wl,-Bstatic
> -lgfortran -Wl,-Bdynamic". I have two questions about this:
>   + linkers other than the GNU linker might have problems with that.
> is there a more general way of doing this? or should it be conditional
> on some macro, like HAVE_LD_STATIC_DYNAMIC?
>   + when -static is used later in the command line, this trick doesn't
> work; would "%{!static:-Wl,-Bstatic} -lgfortran
> %{!static:-Wl,-Bdynamic}" be a good replacement?
> 
> Thanks for the help, I'm a bit a loss with non-GNU linkers... :(
> 
> FX
> 
>   
>   Name: static-libgfortran.diff
>static-libgfortran.diffType: text/x-patch
>   Encoding: base64



Re: New option: -fstatic-libgfortran

2007-04-20 Thread Bernhard Fischer
On Fri, Apr 20, 2007 at 10:15:34AM +0200, François-Xavier Coudert wrote:
>Hi all,
>
>Attached is a first draft of a patch to add a -fstatic-libgfortran
>option. This new option is recognized by the driver and instead of
>adding "-lgfortran" to the various subprocesses, it adds "-Wl,-Bstatic
>-lgfortran -Wl,-Bdynamic". I have two questions about this:
> + linkers other than the GNU linker might have problems with that.
>is there a more general way of doing this? or should it be conditional
>on some macro, like HAVE_LD_STATIC_DYNAMIC?
> + when -static is used later in the command line, this trick doesn't
>work; would "%{!static:-Wl,-Bstatic} -lgfortran
>%{!static:-Wl,-Bdynamic}" be a good replacement?
>
>Thanks for the help, I'm a bit a loss with non-GNU linkers... :(

Perhaps looking at how stuff is done for libgcc.a in
gcc/{Makefile.in,gccspec.c} would help?


Re: New option: -fstatic-libgfortran

2007-04-20 Thread Joseph S. Myers
On Fri, 20 Apr 2007, Fran?ois-Xavier Coudert wrote:

> Attached is a first draft of a patch to add a -fstatic-libgfortran
> option. This new option is recognized by the driver and instead of

I think -static-libgfortran (no initial "f") would be a better spelling, 
for consistency with -static-libgcc.

-- 
Joseph S. Myers
[EMAIL PROTECTED]

New option: -fstatic-libgfortran

2007-04-20 Thread François-Xavier Coudert

Hi all,

Attached is a first draft of a patch to add a -fstatic-libgfortran
option. This new option is recognized by the driver and instead of
adding "-lgfortran" to the various subprocesses, it adds "-Wl,-Bstatic
-lgfortran -Wl,-Bdynamic". I have two questions about this:
 + linkers other than the GNU linker might have problems with that.
is there a more general way of doing this? or should it be conditional
on some macro, like HAVE_LD_STATIC_DYNAMIC?
 + when -static is used later in the command line, this trick doesn't
work; would "%{!static:-Wl,-Bstatic} -lgfortran
%{!static:-Wl,-Bdynamic}" be a good replacement?

Thanks for the help, I'm a bit a loss with non-GNU linkers... :(

FX
Index: lang.opt
===
--- lang.opt	(revision 123942)
+++ lang.opt	(working copy)
@@ -249,6 +249,10 @@
 Fortran
 Use the narrowest integer type possible for enumeration types
 
+fstatic-libgfortran
+Fortran
+Statically link the GNU Fortran helper library (libgfortran)
+
 funderscoring
 Fortran
 Append underscores to externally visible names
Index: options.c
===
--- options.c	(revision 123942)
+++ options.c	(working copy)
@@ -549,6 +549,9 @@
   gfc_option.flag_second_underscore = value;
   break;
 
+case OPT_fstatic_libgfortran:
+  break;
+
 case OPT_fimplicit_none:
   gfc_option.flag_implicit_none = value;
   break;
Index: gfortranspec.c
===
--- gfortranspec.c	(revision 123942)
+++ gfortranspec.c	(working copy)
@@ -82,6 +82,7 @@
    -nodefaultlibs.  */
   OPTION_o,			/* Aka --output.  */
   OPTION_S,			/* Aka --assemble.  */
+  OPTION_static_libgfortran,	/* -fstatic-libgfortran.  */
   OPTION_syntax_only,		/* -fsyntax-only.  */
   OPTION_v,			/* Aka --verbose.  */
   OPTION_version,		/* --version.  */
@@ -170,6 +171,8 @@
 	opt = OPTION_nostdlib;
   else if (!strcmp (text, "-fsyntax-only"))
 	opt = OPTION_syntax_only;
+  else if (!strcmp (text, "-fstatic-libgfortran"))
+	opt = OPTION_static_libgfortran;
   else if (!strcmp (text, "-dumpversion"))
 	opt = OPTION_version;
   else if (!strcmp (text, "-fversion"))	/* Really --version!! */
@@ -265,6 +268,9 @@
   /* By default, we throw on the math library if we have one.  */
   int need_math = (MATH_LIBRARY[0] != '\0');
 
+  /* Whether we should link a static libgfortran.  */
+  int static_lib = 0;
+
   /* The number of input and output files in the incoming arg list.  */
   int n_infiles = 0;
   int n_outfiles = 0;
@@ -323,6 +329,10 @@
 	  library = 0;
 	  break;
 
+	case OPTION_static_libgfortran:
+	  static_lib = 1;
+	  break;
+
 	case OPTION_l:
 	  ++n_infiles;
 	  break;
@@ -468,11 +478,28 @@
 		  append_arg (FORTRAN_INIT);
 		  use_init = 1;
 		}
+
+		  if (static_lib)
+		append_arg ("-Wl,-Bstatic");
 		  append_arg (FORTRAN_LIBRARY);
+		  if (static_lib)
+		append_arg ("-Wl,-Bdynamic");
 		}
 	}
 	  else if (strcmp (argv[i], FORTRAN_LIBRARY) == 0)
-	saw_library = 1;	/* -l.  */
+	{
+	  saw_library = 1;	/* -l.  */
+
+	  if (static_lib)
+		append_arg ("-Wl,-Bstatic");
+	  
+	  append_arg (argv[i]);
+
+	  if (static_lib)
+		append_arg ("-Wl,-Bdynamic");
+
+	  continue;
+	}
 	  else
 	{			/* Other library, or filename.  */
 	  if (saw_library == 1 && need_math)
@@ -498,7 +525,12 @@
 	  append_arg (FORTRAN_INIT);
 	  use_init = 1;
 	}
+
+	  if (static_lib)
+	append_arg ("-Wl,-Bstatic");
 	  append_arg (library);
+	  if (static_lib)
+	append_arg ("-Wl,-Bdynamic");
 	case 1:
 	  if (need_math)
 	append_arg (MATH_LIBRARY);