Index: gcc/gcc.c =================================================================== --- gcc/gcc.c (revision 215887) +++ gcc/gcc.c (working copy) @@ -3723,10 +3723,12 @@ case OPT_static_libgcc: case OPT_shared_libgcc: case OPT_static_libgfortran: + case OPT_static_libquadmath: case OPT_static_libstdc__: /* These are always valid, since gcc.c itself understands the - first two, gfortranspec.c understands -static-libgfortran and - g++spec.c understands -static-libstdc++ */ + first two, gfortranspec.c understands -static-libgfortran + and -static-libquadmath, and g++spec.c understands + -static-libstdc++ */ validated = true; break; Index: gcc/common.opt =================================================================== --- gcc/common.opt (revision 215887) +++ gcc/common.opt (working copy) @@ -2743,6 +2743,10 @@ Driver ; Documented for Fortran, but always accepted by driver. +static-libquadmath +Driver +; Documented for Fortran, but always accepted by driver. + static-libstdc++ Driver Index: gcc/fortran/lang.opt =================================================================== --- gcc/fortran/lang.opt (revision 215887) +++ gcc/fortran/lang.opt (working copy) @@ -661,6 +661,10 @@ Fortran Statically link the GNU Fortran helper library (libgfortran) +static-libquadmath +Fortran +Statically link the quad-math runtime library + std=f2003 Fortran Conform to the ISO Fortran 2003 standard Index: gcc/fortran/invoke.texi =================================================================== --- gcc/fortran/invoke.texi (revision 215887) +++ gcc/fortran/invoke.texi (working copy) @@ -160,7 +160,7 @@ @item Link Options @xref{Link Options,,Options for influencing the linking step}. -@gccoptlist{-static-libgfortran} +@gccoptlist{-static-libgfortran -static-libquadmath} @item Runtime Options @xref{Runtime Options,,Options for influencing runtime behavior}. @@ -1142,6 +1142,16 @@ @end table +@table @gcctabopt +@item -static-libquadmath +@opindex @code{static-libquadmath} +On systems that provide @file{libquadmath} as a shared and a static +library, this option forces the use of the static version. If no +shared version of @file{libquadmath} was built when the compiler was +configured, this option has no effect. +@end table + + @node Runtime Options @section Influencing runtime behavior @cindex options, runtime Index: gcc/fortran/gfortranspec.c =================================================================== --- gcc/fortran/gfortranspec.c (revision 215887) +++ gcc/fortran/gfortranspec.c (working copy) @@ -61,6 +61,10 @@ #define FORTRAN_LIBRARY "gfortran" #endif +#ifndef QUADMATH_LIBRARY +#define QUADMATH_LIBRARY "quadmath" +#endif + /* Name of the spec file. */ #define SPEC_FILE "libgfortran.spec" @@ -160,17 +164,23 @@ } /* Append a libgfortran argument to the list being built. If - FORCE_STATIC, ensure the library is linked statically. */ + FORCE_STATIC, ensure the library is linked statically. If + FORCE_STATIC_LIBQUADMATH, also link the quadmath library statically. */ static void -add_arg_libgfortran (bool force_static ATTRIBUTE_UNUSED) +add_arg_libgfortran (bool force_static ATTRIBUTE_UNUSED, + bool force_static_libquadmath ATTRIBUTE_UNUSED) { #ifdef HAVE_LD_STATIC_DYNAMIC if (force_static) append_option (OPT_Wl_, LD_STATIC_OPTION, 1); #endif + append_option (OPT_l, FORTRAN_LIBRARY, 1); + #ifdef HAVE_LD_STATIC_DYNAMIC + if (force_static_libquadmath) + append_option (OPT_l, QUADMATH_LIBRARY, 1); if (force_static) append_option (OPT_Wl_, LD_DYNAMIC_OPTION, 1); #endif @@ -198,8 +208,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; + /* Whether we should link a static libgfortran / libquadmath. */ + int static_libgfortran = 0; + int static_libquadmath = 0; /* Whether we need to link statically. */ int static_linking = 0; @@ -247,15 +258,21 @@ case OPT_E: /* These options disable linking entirely or linking of the standard libraries. */ - library = 0; + library = NULL; break; case OPT_static_libgfortran: #ifdef HAVE_LD_STATIC_DYNAMIC - static_lib = 1; + static_libgfortran = 1; #endif break; + case OPT_static_libquadmath: +#ifdef HAVE_LD_STATIC_DYNAMIC + static_libquadmath = 1; +#endif + break; + case OPT_static: #ifdef HAVE_LD_STATIC_DYNAMIC static_linking = 1; @@ -300,7 +317,7 @@ /* If there are no input files, no need for the library. */ if (n_infiles == 0) - library = 0; + library = NULL; /* Second pass through arglist, transforming arguments as appropriate. */ @@ -364,13 +381,15 @@ if (saw_library == 1) saw_library = 2; /* -l -lm. */ else - add_arg_libgfortran (static_lib && !static_linking); + add_arg_libgfortran (static_libgfortran && !static_linking, + static_libquadmath && !static_linking); } else if (decoded_options[i].opt_index == OPT_l && strcmp (decoded_options[i].arg, FORTRAN_LIBRARY) == 0) { saw_library = 1; /* -l. */ - add_arg_libgfortran (static_lib && !static_linking); + add_arg_libgfortran (static_libgfortran && !static_linking, + static_libquadmath && !static_linking); continue; } else @@ -393,7 +412,8 @@ switch (saw_library) { case 0: - add_arg_libgfortran (static_lib && !static_linking); + add_arg_libgfortran (static_libgfortran && !static_linking, + static_libquadmath && !static_linking); /* Fall through. */ case 1: Index: gcc/fortran/options.c =================================================================== --- gcc/fortran/options.c (revision 215887) +++ gcc/fortran/options.c (working copy) @@ -861,6 +861,13 @@ #endif break; + case OPT_static_libquadmath: +#ifndef HAVE_LD_STATIC_DYNAMIC + gfc_fatal_error ("-static-libquadmath is not supported in this " + "configuration"); +#endif + break; + case OPT_fimplicit_none: gfc_option.flag_implicit_none = value; break; Index: libgfortran/acinclude.m4 =================================================================== --- libgfortran/acinclude.m4 (revision 215887) +++ libgfortran/acinclude.m4 (working copy) @@ -335,10 +335,11 @@ ]) dnl For static libgfortran linkage, depend on libquadmath only if needed. + dnl If -static-libquadmath is passed, the driver does it for us. if test "x$libgfor_cv_have_as_needed" = xyes; then - LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}" + LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} %{!static-libquadmath:-lquadmath} %{static-libgfortran:$libgfor_cv_no_as_needed_option}" else - LIBQUADSPEC="-lquadmath" + LIBQUADSPEC="%{!static-libquadmath:-lquadmath}" fi if test -f ../libquadmath/libquadmath.la; then LIBQUADLIB=../libquadmath/libquadmath.la