On Fri, Sep 10, 2010 at 07:08:10PM +0200, FX wrote:
> I'm CC'ing the gcc list so I can get insight from people who understand
> correctly how static libraries should be handled by the driver...
>
> > I'm seeing a similar issue with -static linkage.
> >
> > % gfc4x -o z norm2_3.f90 -L/usr/home/sgk/work/lib -lquad -static
>
> OK, I see the same thing. It's due to the fact that when you call:
>
> gfortran mycode.f90 -lquad -static
>
> the linker is called with the following order for the libraries:
>
> -lquad -lgfortran -lm --start-group -lgcc -lgcc_eh -lc --end-group
>
> while libgfortran depends on libquad, so it should be "-lgfortran -lquad".
>
> I'm not very knowledgeable about that, but I think what we can
> have the driver recognized "-lquad" and move it after "-lgfortran".
> That won't handle all cases (what if libquad is called something
> else on your computer? what if you link to a specific version,
> -lquad1.0? what if you link directly by specifying the archive file,
> /path/to/libquad.a?)
>
The ideal solution would be incorporating libquad into libgfortran,
which may option depending on the outcome of Toon's discussion with
the SC. Barring this solution, I think we may need to use the
--with-quad=some_path to define a WITH_QUAD for the fortran frontend.
Then, we modify gfortranspec.c to include -lquad in the proper
order. Don't know if this is doable or not; maybe something like
troutmask:sgk[210] svn diff gfortranspec.c
Index: gfortranspec.c
===================================================================
--- gfortranspec.c (revision 164190)
+++ gfortranspec.c (working copy)
@@ -63,6 +63,10 @@ along with GCC; see the file COPYING3.
#define FORTRAN_LIBRARY "gfortran"
#endif
+#ifndef QUAD_LIBRARY
+#define QUAD_LIBRARY "quad"
+#endif
+
/* The original argument list and related info is copied here. */
static unsigned int g77_xargc;
static const struct cl_decoded_option *g77_x_decoded_options;
@@ -168,6 +172,11 @@ add_arg_libgfortran (bool force_static A
append_option (OPT_Wl_, "-Bstatic", 1);
#endif
append_option (OPT_l, FORTRAN_LIBRARY, 1);
+#if WITH_QUAD
+ /* Need path to libquad, too? */
+ append_option (OPT_l, QUAD_LIBRARY, 1);
+#endif
+
#ifdef HAVE_LD_STATIC_DYNAMIC
if (force_static)
append_option (OPT_Wl_, "-Bdynamic", 1);
--
Steve