FX wrote:
> Patch needs:
>   - C/driver options maintainer, or global reviewer, to OK the C changes 
> (outside darwin). They are really simple
>   - Fortran maintainer to OK the Fortran part
[...]
> >> We have a -static-libgfortran option, but on targets where we support 
> >> quad-prec math through libquadmath, we didnât have an equivalent 
> >> -static-libquadmath so far. This patch adds it, in what I think is a 
> >> rather straightforward manner.
> >> 
> >> The only minor complication comes from the fact that previously, linking 
> >> libquadmath was conditionally through libgfortran.spec. So the spec was 
> >> modified: when we use -static-libquadmath, the driver itself includes the 
> >> -lquadmath (surrounded by the necessary static linking directives), so 
> >> that libgfortran.spec shouldnât do it again.

That unfortunately looses the -as-needed functionality, not that it currently 
works as hoped for.


> >> Bootstrapped and regtested on x86_64 linux. OK to commit?

--- gcc/fortran/gfortranspec.c  (revision 216036)
+++ gcc/fortran/gfortranspec.c  (working copy)
...
+add_arg_libgfortran (bool force_static ATTRIBUTE_UNUSED,
+                    bool force_static_libquadmath ATTRIBUTE_UNUSED)

First, you don't need ATTRIBUTE_UNUSED for force_static_libquadmath as
it is always used.

But my actual problem is that your patch does't seem to work if -static-gfortran
is not in force. You then get:

   append_option (OPT_l, FORTRAN_LIBRARY, 1);
   append_option (OPT_l, QUADMATH_LIBRARY, 1);

instead of:

  append_option (OPT_l, FORTRAN_LIBRARY, 1);

  append_option (OPT_Wl_, LD_STATIC_OPTION, 1);
  append_option (OPT_l, QUADMATH_LIBRARY, 1);
  append_option (OPT_Wl_, LD_DYNAMIC_OPTION, 1);

Additionally, I wonder whether you need the
 #ifdef HAVE_LD_STATIC_DYNAMIC
...
+#else
+  if (force_static_libquadmath)
+    append_option (OPT_l, QUADMATH_LIBRARY, 1);

at all, given that you have in:

Index: gcc/fortran/options.c
...
+    case OPT_static_libquadmath:
+#ifndef HAVE_LD_STATIC_DYNAMIC
+      gfc_fatal_error ("-static-libquadmath is not supported in this "
+                      "configuration");
+#endif
+      break;

and that without -static-lquadmath, the -lquadmath is added - with as-needed -
in libgfortran's .spec file. (Mentioning this in gfortranspec.c wouldn't harm,
I'd presume.)

(NB: If you remove the #else, you do need the ATTRIBUTE_UNUSED, again.)

Tobias

Reply via email to