Index: gcc/common.opt =================================================================== --- gcc/common.opt (revision 216036) +++ gcc/common.opt (working copy) @@ -2743,6 +2743,10 @@ static-libgfortran 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/gcc.c =================================================================== --- gcc/gcc.c (revision 216036) +++ gcc/gcc.c (working copy) @@ -3723,10 +3723,12 @@ driver_handle_option (struct gcc_options 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/config/darwin.h =================================================================== --- gcc/config/darwin.h (revision 216036) +++ gcc/config/darwin.h (working copy) @@ -229,6 +229,7 @@ extern GTY(()) int darwin_ms_struct; %:replace-outfile(-lobjc libobjc-gnu.a%s); \ :%:replace-outfile(-lobjc -lobjc-gnu ) } }\ %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\ + %{static|static-libgcc|static-libquadmath:%:replace-outfile(-lquadmath libquadmath.a%s)}\ %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\ %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\ %{!Zdynamiclib: \ Index: gcc/fortran/gfortranspec.c =================================================================== --- gcc/fortran/gfortranspec.c (revision 216036) +++ gcc/fortran/gfortranspec.c (working copy) @@ -61,6 +61,10 @@ along with GCC; see the file COPYING3. #define FORTRAN_LIBRARY "gfortran" #endif +#ifndef QUADMATH_LIBRARY +#define QUADMATH_LIBRARY "quadmath" +#endif + /* Name of the spec file. */ #define SPEC_FILE "libgfortran.spec" @@ -160,19 +164,28 @@ append_option (size_t opt_index, const c } /* 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); +#else + if (force_static_libquadmath) + append_option (OPT_l, QUADMATH_LIBRARY, 1); #endif } @@ -198,8 +211,9 @@ lang_specific_driver (struct cl_decoded_ /* 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,12 +261,18 @@ lang_specific_driver (struct cl_decoded_ 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; @@ -300,7 +320,7 @@ For more information about these matters /* 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 +384,15 @@ For more information about these matters 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 +415,8 @@ For more information about these matters 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/invoke.texi =================================================================== --- gcc/fortran/invoke.texi (revision 216036) +++ gcc/fortran/invoke.texi (working copy) @@ -160,7 +160,7 @@ and warnings}. @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,20 @@ configured, this option has no effect. @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. + +Please note that the @file{libquadmath} runtime library is under the GNU +Library General Public License (LGPL), and linking it statically introduces +requirements on redistributing the resulting binaries. +@end table + + @node Runtime Options @section Influencing runtime behavior @cindex options, runtime Index: gcc/fortran/lang.opt =================================================================== --- gcc/fortran/lang.opt (revision 216036) +++ gcc/fortran/lang.opt (working copy) @@ -665,6 +665,10 @@ static-libgfortran 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/options.c =================================================================== --- gcc/fortran/options.c (revision 216036) +++ gcc/fortran/options.c (working copy) @@ -869,6 +869,13 @@ gfc_handle_option (size_t scode, const c #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 216036) +++ libgfortran/acinclude.m4 (working copy) @@ -335,10 +335,11 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [ ]) 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