Blame SOURCES/gcc11-static-libquadmath.patch

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