Blame SOURCES/gcc12-static-libquadmath.patch

d6dcb6
2022-08-17  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
d6dcb6
	    Jakub Jelinek  <jakub@redhat.com>
d6dcb6
d6dcb6
	PR fortran/46539
d6dcb6
gcc/
d6dcb6
	* common.opt (static-libquadmath): New option.
d6dcb6
	* gcc.cc (driver_handle_option): Always accept -static-libquadmath.
d6dcb6
	* config/darwin.h (LINK_SPEC): Handle -static-libquadmath.
d6dcb6
gcc/fortran/
d6dcb6
	* lang.opt (static-libquadmath): New option.
d6dcb6
	* invoke.texi (-static-libquadmath): Document it.
d6dcb6
libgfortran/
d6dcb6
	* acinclude.m4 (LIBQUADSPEC): From $FC -static-libgfortran -###
d6dcb6
	output determine -Bstatic/-Bdynamic, -bstatic/-bdynamic,
d6dcb6
	-aarchive_shared/-adefault linker support or Darwin remapping
d6dcb6
	of -lgfortran to libgfortran.a%s and use that around or instead
d6dcb6
	of -lquadmath in LIBQUADSPEC.
d6dcb6
	* configure: Regenerated.
d6dcb6
d6dcb6
--- gcc/common.opt.jj	2022-04-28 15:56:02.822846833 +0200
d6dcb6
+++ gcc/common.opt	2022-09-29 19:41:37.250880668 +0200
d6dcb6
@@ -3563,6 +3563,10 @@ static-libphobos
d6dcb6
 Driver
d6dcb6
 ; Documented for D, but always accepted by driver.
d6dcb6
 
d6dcb6
+static-libquadmath
d6dcb6
+Driver
d6dcb6
+; Documented for Fortran, but always accepted by driver.
d6dcb6
+
d6dcb6
 static-libstdc++
d6dcb6
 Driver
d6dcb6
 
d6dcb6
--- gcc/gcc.cc.jj	2022-04-28 15:56:04.771819920 +0200
d6dcb6
+++ gcc/gcc.cc	2022-09-29 19:41:37.296880041 +0200
d6dcb6
@@ -4583,12 +4583,14 @@ driver_handle_option (struct gcc_options
d6dcb6
     case OPT_static_libgcc:
d6dcb6
     case OPT_shared_libgcc:
d6dcb6
     case OPT_static_libgfortran:
d6dcb6
+    case OPT_static_libquadmath:
d6dcb6
     case OPT_static_libphobos:
d6dcb6
     case OPT_static_libstdc__:
d6dcb6
       /* These are always valid, since gcc.cc itself understands the
d6dcb6
 	 first two, gfortranspec.cc understands -static-libgfortran,
d6dcb6
-	 d-spec.cc understands -static-libphobos, and g++spec.cc
d6dcb6
-	 understands -static-libstdc++ */
d6dcb6
+	 d-spec.cc understands -static-libphobos, g++spec.cc
d6dcb6
+	 understands -static-libstdc++ and libgfortran.spec handles
d6dcb6
+	 -static-libquadmath.  */
d6dcb6
       validated = true;
d6dcb6
       break;
d6dcb6
 
d6dcb6
--- gcc/config/darwin.h.jj	2022-06-18 21:56:40.666675606 +0200
d6dcb6
+++ gcc/config/darwin.h	2022-09-29 19:41:37.261880518 +0200
d6dcb6
@@ -443,6 +443,7 @@ extern GTY(()) int darwin_ms_struct;
d6dcb6
                      %:replace-outfile(-lobjc libobjc-gnu.a%s); \
d6dcb6
                     :%:replace-outfile(-lobjc -lobjc-gnu )}}\
d6dcb6
    %{static|static-libgcc|static-libgfortran:%:replace-outfile(-lgfortran libgfortran.a%s)}\
d6dcb6
+   %{static|static-libgcc|static-libquadmath:%:replace-outfile(-lquadmath libquadmath.a%s)}\
d6dcb6
    %{static|static-libgcc|static-libphobos:%:replace-outfile(-lgphobos libgphobos.a%s)}\
d6dcb6
    %{static|static-libgcc|static-libstdc++|static-libgfortran:%:replace-outfile(-lgomp libgomp.a%s)}\
d6dcb6
    %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ libstdc++.a%s)}\
d6dcb6
--- gcc/fortran/lang.opt.jj	2022-04-28 15:56:04.579822571 +0200
d6dcb6
+++ gcc/fortran/lang.opt	2022-09-29 19:41:37.279880273 +0200
d6dcb6
@@ -863,6 +863,10 @@ static-libgfortran
d6dcb6
 Fortran
d6dcb6
 Statically link the GNU Fortran helper library (libgfortran).
d6dcb6
 
d6dcb6
+static-libquadmath
d6dcb6
+Driver
d6dcb6
+Statically link the GCC Quad-Precision Math Library (libquadmath).
d6dcb6
+
d6dcb6
 std=f2003
d6dcb6
 Fortran
d6dcb6
 Conform to the ISO Fortran 2003 standard.
d6dcb6
--- gcc/fortran/invoke.texi.jj	2022-04-29 15:51:59.080720092 +0200
d6dcb6
+++ gcc/fortran/invoke.texi	2022-09-29 19:41:37.273880354 +0200
d6dcb6
@@ -170,7 +170,7 @@ and warnings}.
d6dcb6
 
d6dcb6
 @item Link Options
d6dcb6
 @xref{Link Options,,Options for influencing the linking step}.
d6dcb6
-@gccoptlist{-static-libgfortran}
d6dcb6
+@gccoptlist{-static-libgfortran  -static-libquadmath}
d6dcb6
 
d6dcb6
 @item Runtime Options
d6dcb6
 @xref{Runtime Options,,Options for influencing runtime behavior}.
d6dcb6
@@ -1425,6 +1425,20 @@ configured, this option has no effect.
d6dcb6
 @end table
d6dcb6
 
d6dcb6
 
d6dcb6
+@table @gcctabopt
d6dcb6
+@item -static-libquadmath
d6dcb6
+@opindex @code{static-libquadmath}
d6dcb6
+On systems that provide @file{libquadmath} as a shared and a static
d6dcb6
+library, this option forces the use of the static version. If no
d6dcb6
+shared version of @file{libquadmath} was built when the compiler was
d6dcb6
+configured, this option has no effect.
d6dcb6
+
d6dcb6
+Please note that the @file{libquadmath} runtime library is licensed under the
d6dcb6
+GNU Lesser General Public License (LGPL), and linking it statically introduces
d6dcb6
+requirements when redistributing the resulting binaries.
d6dcb6
+@end table
d6dcb6
+
d6dcb6
+
d6dcb6
 @node Runtime Options
d6dcb6
 @section Influencing runtime behavior
d6dcb6
 @cindex options, runtime
d6dcb6
--- libgfortran/acinclude.m4.jj	2022-09-29 19:41:37.306879904 +0200
d6dcb6
+++ libgfortran/acinclude.m4	2022-09-29 19:42:42.641988408 +0200
d6dcb6
@@ -338,11 +338,32 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
d6dcb6
       ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
d6dcb6
     ])
d6dcb6
 
d6dcb6
+    dnl Determine -Bstatic ... -Bdynamic etc. support from gfortran -### stderr.
d6dcb6
+    touch conftest1.$ac_objext conftest2.$ac_objext
d6dcb6
+    LQUADMATH=-lquadmath
d6dcb6
+    $FC -static-libgfortran -### -o conftest \
d6dcb6
+	conftest1.$ac_objext -lgfortran conftest2.$ac_objext 2>&1 >/dev/null \
d6dcb6
+	| grep "conftest1.$ac_objext.*conftest2.$ac_objext" > conftest.cmd
d6dcb6
+    if grep "conftest1.$ac_objext.* -Bstatic -lgfortran -Bdynamic .*conftest2.$ac_objext" \
d6dcb6
+       conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:-Bstatic} -lquadmath %{static-libquadmath:-Bdynamic}"
d6dcb6
+    elif grep "conftest1.$ac_objext.* -bstatic -lgfortran -bdynamic .*conftest2.$ac_objext" \
d6dcb6
+         conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:-bstatic} -lquadmath %{static-libquadmath:-bdynamic}"
d6dcb6
+    elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran -adefault .*conftest2.$ac_objext" \
d6dcb6
+         conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:-aarchive_shared} -lquadmath %{static-libquadmath:-adefault}"
d6dcb6
+    elif grep "conftest1.$ac_objext.*libgfortran.a .*conftest2.$ac_objext" \
d6dcb6
+         conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:libquadmath.a%s;:-lquadmath}"
d6dcb6
+    fi
d6dcb6
+    rm -f conftest1.$ac_objext conftest2.$ac_objext conftest conftest.cmd
d6dcb6
+
d6dcb6
     dnl For static libgfortran linkage, depend on libquadmath only if needed.
d6dcb6
     if test "x$libgfor_cv_have_as_needed" = xyes; then
d6dcb6
-      LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
d6dcb6
+      LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
d6dcb6
     else
d6dcb6
-      LIBQUADSPEC="-lquadmath"
d6dcb6
+      LIBQUADSPEC="$LQUADMATH"
d6dcb6
     fi
d6dcb6
     if test -f ../libquadmath/libquadmath.la; then
d6dcb6
       LIBQUADLIB=../libquadmath/libquadmath.la
d6dcb6
--- libgfortran/configure.jj	2022-09-29 19:41:37.345879372 +0200
d6dcb6
+++ libgfortran/configure	2022-09-29 19:42:59.878753212 +0200
d6dcb6
@@ -27301,10 +27301,30 @@ fi
d6dcb6
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgfor_cv_have_as_needed" >&5
d6dcb6
 $as_echo "$libgfor_cv_have_as_needed" >&6; }
d6dcb6
 
d6dcb6
+        touch conftest1.$ac_objext conftest2.$ac_objext
d6dcb6
+    LQUADMATH=-lquadmath
d6dcb6
+    $FC -static-libgfortran -### -o conftest \
d6dcb6
+	conftest1.$ac_objext -lgfortran conftest2.$ac_objext 2>&1 >/dev/null \
d6dcb6
+	| grep "conftest1.$ac_objext.*conftest2.$ac_objext" > conftest.cmd
d6dcb6
+    if grep "conftest1.$ac_objext.* -Bstatic -lgfortran -Bdynamic .*conftest2.$ac_objext" \
d6dcb6
+       conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:-Bstatic} -lquadmath %{static-libquadmath:-Bdynamic}"
d6dcb6
+    elif grep "conftest1.$ac_objext.* -bstatic -lgfortran -bdynamic .*conftest2.$ac_objext" \
d6dcb6
+         conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:-bstatic} -lquadmath %{static-libquadmath:-bdynamic}"
d6dcb6
+    elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran -adefault .*conftest2.$ac_objext" \
d6dcb6
+         conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:-aarchive_shared} -lquadmath %{static-libquadmath:-adefault}"
d6dcb6
+    elif grep "conftest1.$ac_objext.*libgfortran.a .*conftest2.$ac_objext" \
d6dcb6
+         conftest.cmd >/dev/null 2>&1; then
d6dcb6
+      LQUADMATH="%{static-libquadmath:libquadmath.a%s;:-lquadmath}"
d6dcb6
+    fi
d6dcb6
+    rm -f conftest1.$ac_objext conftest2.$ac_objext conftest conftest.cmd
d6dcb6
+
d6dcb6
         if test "x$libgfor_cv_have_as_needed" = xyes; then
d6dcb6
-      LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
d6dcb6
+      LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
d6dcb6
     else
d6dcb6
-      LIBQUADSPEC="-lquadmath"
d6dcb6
+      LIBQUADSPEC="$LQUADMATH"
d6dcb6
     fi
d6dcb6
     if test -f ../libquadmath/libquadmath.la; then
d6dcb6
       LIBQUADLIB=../libquadmath/libquadmath.la