From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 2E9973858D28; Thu, 18 Aug 2022 10:35:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E9973858D28 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=googlemail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=googlemail.com Received: by mail-wm1-x331.google.com with SMTP id p12-20020a7bcc8c000000b003a5360f218fso2362683wma.3; Thu, 18 Aug 2022 03:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc; bh=jTGKSkXamd1Tj6qfmRBVexKIUF43itxgl3R3q7ghWa0=; b=jQP6l/i/nnBhuxosjp97qqeOs3zFXfo+hGg1IPCAi6o1aRpaGSCaGgY0Q2xmjHnH0X S740oTuBwxAkrpGdQXsi2B1VDYxoC2opfmeBTImAUHI78AF6XDB8Q+7TkJAMoZpbo0CF bcJ7JFNIP6yhV8yhMlCGCkOVE3UFcufq2v8gcBTkSR0R7smTm0T4OmqMlXXEc6QFe74B lBDx7LE7lmf0FLaIArELLiLcGVUBFK6JUAJ8PrDoUFBssrcwbowoDqcSBynAQMDOPie0 sOpi22eC4Z/ZUy+nyvlAUK9UhaUWxCnfDkKohl2Qou5pPT1ySEYbza+hTDqRLGA8+TMQ wXGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc; bh=jTGKSkXamd1Tj6qfmRBVexKIUF43itxgl3R3q7ghWa0=; b=j9gHOibArd6w7sMbAxtxBEGRVA/Cl0c3sMMiJnlBDNHsaTKq4iPODT4fKmDcflFc4E L5P14nB79RMhTZOq0zN0hALB4vcAnjH6lCAFs7hE/LuDsBUlYO/1XANnj7xVuoscGWaz sG6w4uMv9PPwM4/jSMtXAuiq2mDYT0eNEG2wTJVy7/TVDbp/+Z5KnKYgrAGXciz2Anrz 8EqZKX0oBrAaUgR0xbqqFhDnjTpgPz2fbh9XMDPGNMvt7rw7Gi0dJ8A2hMk00pSSnb+1 ZllxuK7oDIOLwP6j33+8RdvrNCmDdUhz26/z7UR1D23pvfKcyPp4KI+BgnV9ipv+gTfG oWAA== X-Gm-Message-State: ACgBeo3YIGnF6hfjMn8VAldyULSBExOAAu/b2I8KNd+lRsjfh6gMt83Y AP262mGKZfxRrzl9NUG3SR4= X-Google-Smtp-Source: AA6agR74pVgr3Y+HlrYE38ucnz8JeupOZMIY1Ab2ClTJCGqfAC6poT0vSzR0EkWJqGLoOqFjo5kd2Q== X-Received: by 2002:a05:600c:1e8d:b0:3a5:e37f:6fd2 with SMTP id be13-20020a05600c1e8d00b003a5e37f6fd2mr4645349wmb.33.1660818907831; Thu, 18 Aug 2022 03:35:07 -0700 (PDT) Received: from [192.168.1.95] (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.googlemail.com with ESMTPSA id u5-20020a5d4685000000b0022526db2363sm1081601wrq.30.2022.08.18.03.35.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Aug 2022 03:35:07 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: [PATCH] fortran, v2: Add -static-libquadmath support [PR46539] From: Iain Sandoe In-Reply-To: Date: Thu, 18 Aug 2022 11:35:06 +0100 Cc: Mikael Morin , GCC Patches , GCC Fortran Content-Transfer-Encoding: quoted-printable Message-Id: <55BAB9E6-B67B-4686-BAFD-AB06C0740990@googlemail.com> References: To: Jakub Jelinek X-Mailer: Apple Mail (2.3608.120.23.2.7) X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Aug 2022 10:35:11 -0000 Hi Folks > On 17 Aug 2022, at 12:05, Jakub Jelinek via Fortran = wrote: >=20 > On Wed, Aug 17, 2022 at 10:28:29AM +0200, Mikael Morin wrote: >> Tobias approved it already, but I spotted what looks like typos. >> See below. >=20 > Thanks for catching that. >=20 >>> --- gcc/config/darwin.h.jj 2022-08-16 14:51:14.529544492 +0200 >>> +++ gcc/config/darwin.h 2022-08-16 14:53:54.402460097 +0200 >>> @@ -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-libgfortran:%:replace-outfile(-lquadmath = libquadmath.a%s)}\ >>=20 >> s/static-libgfortran/static-libquadmath/ I guess? Otherwise I = don=E2=80=99t >> understand the corresponding ChangeLog description. >=20 > Yeah. I just copied this part from the 2014 patch and didn't spot = that. >=20 >>> + elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran = -adefault .*conftest2.$ac_objext" \ >>> + conftest.cmd >/dev/null 2>&1; then >>> + LQUADMATH=3D"%{static-libquadmath:-aarchive_shared} = -lquadmath %{static-libquadmath:-adefault}" >>> + elif grep "conftest1.$ac_objext.* ligfortran.a = .*conftest2.$ac_objext" \ >>=20 >> s/ligfortran.a/libgfortran.a/ >=20 > Indeed. Also removed the space before libgfortran.a because I'm not = sure if > it won't have because of the %s full path in front of that. > This is Darwin only stuff. > I must say I don't know if even this elif ... LQUADMATH part is = needed, > maybe replace-outfile will rename even the -lquadmath from the spec = file. >=20 > Here is an updated version (but nothing relevant to Linux changed, so = there > is no point for me to bootstrap/regtest it again): >=20 > 2022-08-17 Francois-Xavier Coudert > Jakub Jelinek >=20 > PR fortran/46539 > gcc/ > * common.opt (static-libquadmath): New option. > * gcc.c (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.c (gfc_handle_option): Error out if = -static-libquadmath > is passed but we do not support it. > libgfortran/ > * acinclude.m4 (LIBQUADSPEC): =46rom $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. >=20 > --- gcc/common.opt.jj 2022-06-27 11:18:02.050066582 +0200 > +++ gcc/common.opt 2022-08-16 14:51:04.611673800 +0200 > @@ -3601,6 +3601,10 @@ static-libphobos > Driver > ; Documented for D, but always accepted by driver. >=20 > +static-libquadmath > +Driver > +; Documented for Fortran, but always accepted by driver. > + > static-libstdc++ > Driver >=20 > --- gcc/gcc.cc.jj 2022-08-11 09:57:24.765334380 +0200 > +++ gcc/gcc.cc 2022-08-16 14:57:54.708327024 +0200 > @@ -4585,12 +4585,14 @@ 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_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 =3D true; > break; >=20 > --- gcc/config/darwin.h.jj 2022-08-16 14:51:14.529544492 +0200 > +++ gcc/config/darwin.h 2022-08-16 14:53:54.402460097 +0200 > @@ -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-outfi= le(-lgomp libgomp.a%s)}\ > %{static|static-libgcc|static-libstdc++:%:replace-outfile(-lstdc++ = libstdc++.a%s)}\ > --- gcc/fortran/lang.opt.jj 2022-02-04 14:36:55.050604670 +0100 > +++ gcc/fortran/lang.opt 2022-08-16 14:52:52.459267705 +0200 > @@ -863,6 +863,10 @@ static-libgfortran > Fortran > Statically link the GNU Fortran helper library (libgfortran). >=20 > +static-libquadmath > +Fortran > +Statically link the GCC Quad-Precision Math Library (libquadmath). > + > std=3Df2003 > Fortran > Conform to the ISO Fortran 2003 standard. > --- gcc/fortran/options.cc.jj 2022-01-18 11:58:59.568982256 +0100 > +++ gcc/fortran/options.cc 2022-08-16 14:56:22.807525218 +0200 > @@ -692,6 +692,13 @@ gfc_handle_option (size_t scode, const c > #endif > break; >=20 > + case OPT_static_libquadmath: > +#ifndef HAVE_LD_STATIC_DYNAMIC > + gfc_fatal_error ("%<-static-libquadmath%> is not supported in = this " > + "configuration"); > +#endif I think that this will disable the option on Darwin (where the linker = does not support Bstatic/dynamic) - the point of the specs outfile substitution = is to work for such platforms. So long as the option is not stripped out by the = driver, the specs substitution should work (there is a bug in the g++ driver where = this is not happening properly for -static-libstdc++ - but the gdc driver has it = right). Iain > + break; > + > case OPT_fintrinsic_modules_path: > case OPT_fintrinsic_modules_path_: >=20 > --- gcc/fortran/invoke.texi.jj 2022-05-09 09:09:20.312473272 = +0200 > +++ gcc/fortran/invoke.texi 2022-08-16 16:12:47.638203577 +0200 > @@ -170,7 +170,7 @@ and warnings}. >=20 > @item Link Options > @xref{Link Options,,Options for influencing the linking step}. > -@gccoptlist{-static-libgfortran} > +@gccoptlist{-static-libgfortran -static-libquadmath} >=20 > @item Runtime Options > @xref{Runtime Options,,Options for influencing runtime behavior}. > @@ -1425,6 +1425,20 @@ configured, this option has no effect. > @end table >=20 >=20 > +@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 > --- libgfortran/acinclude.m4.jj 2022-06-29 17:05:45.478790781 = +0200 > +++ libgfortran/acinclude.m4 2022-08-16 16:06:50.047814043 +0200 > @@ -356,18 +356,39 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [ > = ac_[]_AC_LANG_ABBREV[]_werror_flag=3D$ac_xsave_[]_AC_LANG_ABBREV[]_werror_= flag > ]) >=20 > + dnl Determine -Bstatic ... -Bdynamic etc. support from gfortran = -### stderr. > + touch conftest1.$ac_objext conftest2.$ac_objext > + LQUADMATH=3D-lquadmath > + $FC -static-libgfortran -### -o conftest \ > + conftest1.$ac_objext -lgfortran conftest2.$ac_objext 2>&1 = >/dev/null \ > + | grep "conftest1.$ac_objext.*conftest2.$ac_objext" > = conftest.cmd > + if grep "conftest1.$ac_objext.* -Bstatic -lgfortran -Bdynamic = .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:-Bstatic} -lquadmath = %{static-libquadmath:-Bdynamic}" > + elif grep "conftest1.$ac_objext.* -bstatic -lgfortran -bdynamic = .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:-bstatic} -lquadmath = %{static-libquadmath:-bdynamic}" > + elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran = -adefault .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:-aarchive_shared} -lquadmath = %{static-libquadmath:-adefault}" > + elif grep "conftest1.$ac_objext.*libgfortran.a = .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:libquadmath.a%s;:-lquadmath}" > + fi > + rm -f conftest1.$ac_objext conftest2.$ac_objext conftest = conftest.cmd > + > dnl For static libgfortran linkage, depend on libquadmath only if = needed. > dnl If using *f128 APIs from libc/libm, depend on libquadmath only = if needed > dnl even for dynamic libgfortran linkage, and don't link = libgfortran against > dnl -lquadmath. > if test "x$libgfor_cv_have_as_needed" =3D xyes; then > if test "x$USE_IEC_60559" =3D xyes; then > - LIBQUADSPEC=3D"$libgfor_cv_as_needed_option -lquadmath = $libgfor_cv_no_as_needed_option" > + LIBQUADSPEC=3D"$libgfor_cv_as_needed_option $LQUADMATH = $libgfor_cv_no_as_needed_option" > else > - LIBQUADSPEC=3D"%{static-libgfortran:$libgfor_cv_as_needed_option} = -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}" > + LIBQUADSPEC=3D"%{static-libgfortran:$libgfor_cv_as_needed_option} = $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}" > fi > else > - LIBQUADSPEC=3D"-lquadmath" > + LIBQUADSPEC=3D"$LQUADMATH" > fi > if test "x$USE_IEC_60559" !=3D xyes; then > if test -f ../libquadmath/libquadmath.la; then > --- libgfortran/configure.jj 2022-06-29 17:05:45.483790716 +0200 > +++ libgfortran/configure 2022-08-16 16:06:54.119761574 +0200 > @@ -30323,14 +30323,34 @@ fi > { $as_echo "$as_me:${as_lineno-$LINENO}: result: = $libgfor_cv_have_as_needed" >&5 > $as_echo "$libgfor_cv_have_as_needed" >&6; } >=20 > + touch conftest1.$ac_objext conftest2.$ac_objext > + LQUADMATH=3D-lquadmath > + $FC -static-libgfortran -### -o conftest \ > + conftest1.$ac_objext -lgfortran conftest2.$ac_objext 2>&1 = >/dev/null \ > + | grep "conftest1.$ac_objext.*conftest2.$ac_objext" > = conftest.cmd > + if grep "conftest1.$ac_objext.* -Bstatic -lgfortran -Bdynamic = .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:-Bstatic} -lquadmath = %{static-libquadmath:-Bdynamic}" > + elif grep "conftest1.$ac_objext.* -bstatic -lgfortran -bdynamic = .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:-bstatic} -lquadmath = %{static-libquadmath:-bdynamic}" > + elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran = -adefault .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:-aarchive_shared} -lquadmath = %{static-libquadmath:-adefault}" > + elif grep "conftest1.$ac_objext.*libgfortran.a = .*conftest2.$ac_objext" \ > + conftest.cmd >/dev/null 2>&1; then > + LQUADMATH=3D"%{static-libquadmath:libquadmath.a%s;:-lquadmath}" > + fi > + rm -f conftest1.$ac_objext conftest2.$ac_objext conftest = conftest.cmd > + > if test "x$libgfor_cv_have_as_needed" =3D xyes; = then > if test "x$USE_IEC_60559" =3D xyes; then > - LIBQUADSPEC=3D"$libgfor_cv_as_needed_option -lquadmath = $libgfor_cv_no_as_needed_option" > + LIBQUADSPEC=3D"$libgfor_cv_as_needed_option $LQUADMATH = $libgfor_cv_no_as_needed_option" > else > - LIBQUADSPEC=3D"%{static-libgfortran:$libgfor_cv_as_needed_option} = -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}" > + LIBQUADSPEC=3D"%{static-libgfortran:$libgfor_cv_as_needed_option} = $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}" > fi > else > - LIBQUADSPEC=3D"-lquadmath" > + LIBQUADSPEC=3D"$LQUADMATH" > fi > if test "x$USE_IEC_60559" !=3D xyes; then > if test -f ../libquadmath/libquadmath.la; then >=20 >=20 > Jakub >=20