diff options
author | Jakub Jelinek <jakub@redhat.com> | 2022-08-17 17:00:33 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2022-08-17 17:03:30 +0200 |
commit | 745be54bd6634fe63d6be83615e264c83d2ae9f9 (patch) | |
tree | 234d7a6f04483a8a083d4532cb76ae6da0930dc9 /gcc | |
parent | 1513512ec7d0751cba30c9c8804f2be462acfb9b (diff) | |
download | gcc-745be54bd6634fe63d6be83615e264c83d2ae9f9.zip gcc-745be54bd6634fe63d6be83615e264c83d2ae9f9.tar.gz gcc-745be54bd6634fe63d6be83615e264c83d2ae9f9.tar.bz2 |
fortran: Add -static-libquadmath support [PR46539]
The following patch is a revival of the
https://gcc.gnu.org/legacy-ml/gcc-patches/2014-10/msg00771.html
patch. While trunk configured against recent glibc and with linker
--as-needed support doesn't really need to link against -lquadmath
anymore, there are still other targets where libquadmath is still in
use.
As has been discussed, making -static-libgfortran imply statically
linking both libgfortran and libquadmath is undesirable because of
the significant licensing differences between the 2 libraries.
Compared to the 2014 patch, this one doesn't handle -lquadmath
addition in the driver, which to me looks incorrect, libgfortran
configure determines where in libgfortran.spec -lquadmath should
be present if at all and with what it should be wrapped, but
analyzes gfortran -### -static-libgfortran stderr and based on
that figures out what gcc/configure.ac determined.
2022-08-17 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Jakub Jelinek <jakub@redhat.com>
PR fortran/46539
gcc/
* common.opt (static-libquadmath): New option.
* gcc.cc (driver_handle_option): Always accept -static-libquadmath.
* config/darwin.h (LINK_SPEC): Handle -static-libquadmath.
gcc/fortran/
* lang.opt (static-libquadmath): New option.
* invoke.texi (-static-libquadmath): Document it.
* options.cc (gfc_handle_option): Error out if -static-libquadmath
is passed but we do not support it.
libgfortran/
* acinclude.m4 (LIBQUADSPEC): From $FC -static-libgfortran -###
output determine -Bstatic/-Bdynamic, -bstatic/-bdynamic,
-aarchive_shared/-adefault linker support or Darwin remapping
of -lgfortran to libgfortran.a%s and use that around or instead
of -lquadmath in LIBQUADSPEC.
* configure: Regenerated.
Co-Authored-By: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/common.opt | 4 | ||||
-rw-r--r-- | gcc/config/darwin.h | 1 | ||||
-rw-r--r-- | gcc/fortran/invoke.texi | 16 | ||||
-rw-r--r-- | gcc/fortran/lang.opt | 4 | ||||
-rw-r--r-- | gcc/fortran/options.cc | 7 | ||||
-rw-r--r-- | gcc/gcc.cc | 6 |
6 files changed, 35 insertions, 3 deletions
diff --git a/gcc/common.opt b/gcc/common.opt index e7a51e8..fba90ff 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -3601,6 +3601,10 @@ static-libphobos Driver ; Documented for D, but always accepted by driver. +static-libquadmath +Driver +; Documented for Fortran, but always accepted by driver. + static-libstdc++ Driver diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index f82ec62..c5e1ba8 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -443,6 +443,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-libphobos:%:replace-outfile(-lgphobos libgphobos.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)}\ diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index c0932f6..4d1e0d6 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -170,7 +170,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}. @@ -1425,6 +1425,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 licensed under the +GNU Lesser General Public License (LGPL), and linking it statically introduces +requirements when redistributing the resulting binaries. +@end table + + @node Runtime Options @section Influencing runtime behavior @cindex options, runtime diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt index cf39712..e8cd735 100644 --- a/gcc/fortran/lang.opt +++ b/gcc/fortran/lang.opt @@ -863,6 +863,10 @@ static-libgfortran Fortran Statically link the GNU Fortran helper library (libgfortran). +static-libquadmath +Fortran +Statically link the GCC Quad-Precision Math Library (libquadmath). + std=f2003 Fortran Conform to the ISO Fortran 2003 standard. diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index d0fa634..38249d6 100644 --- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -692,6 +692,13 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, #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_fintrinsic_modules_path: case OPT_fintrinsic_modules_path_: @@ -4585,12 +4585,14 @@ driver_handle_option (struct gcc_options *opts, case OPT_static_libgcc: case OPT_shared_libgcc: case OPT_static_libgfortran: + case OPT_static_libquadmath: case OPT_static_libphobos: case OPT_static_libstdc__: /* These are always valid, since gcc.cc itself understands the first two, gfortranspec.cc understands -static-libgfortran, - d-spec.cc understands -static-libphobos, and g++spec.cc - understands -static-libstdc++ */ + d-spec.cc understands -static-libphobos, g++spec.cc + understands -static-libstdc++ and libgfortran.spec handles + -static-libquadmath. */ validated = true; break; |