Re: [PATCH] fortran: Add -static-libquadmath support [PR46539]
On Tue, Aug 16, 2022 at 04:31:03PM +0200, Jakub Jelinek via Gcc-patches wrote: > So far slightly tested on x86_64-linux (and will bootstrap/regtest > it there tonight), but I unfortunately don't have a way to test it FYI, successfully bootstrapped/regtested on x86_64-linux and i686-linux. > 2022-08-16 Francois-Xavier Coudert > Jakub Jelinek > > 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): 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. Jakub
Re: [PATCH] fortran: Add -static-libquadmath support [PR46539]
On 16.08.22 16:31, Jakub Jelinek via Gcc-patches wrote: 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. [...] So far slightly tested on x86_64-linux (and will bootstrap/regtest it there tonight), but I unfortunately don't have a way to test it e.g. on Darwin. Thoughts on this? Looks good to me – with the caveat of having only limited knowledge of .spec and Darwin. --- gcc/fortran/invoke.texi.jj2022-05-09 09:09:20.312473272 +0200 +++ gcc/fortran/invoke.texi 2022-08-16 16:12:47.638203577 +0200 ... +Please note that the @file{libquadmath} runtime library is licensed under the +GNU Lesser General Public License (LGPL), and linking it statically introduces +requirements on redistributing the resulting binaries. "on redistributing" sounds odd to me – "when redistributing" or "on (the) redistribution of" sounds better to me. Tobias - Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
Re: [PATCH] fortran: Add -static-libquadmath support [PR46539]
Hello, Tobias approved it already, but I spotted what looks like typos. See below. Mikael 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/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)}\ s/static-libgfortran/static-libquadmath/ I guess? Otherwise I don’t understand the corresponding ChangeLog description. %{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)}\ (...) --- libgfortran/acinclude.m4.jj 2022-06-29 17:05:45.478790781 +0200 +++ libgfortran/acinclude.m42022-08-16 16:06:50.047814043 +0200 @@ -356,18 +356,39 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [ ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag ]) +dnl Determine -Bstatic ... -Bdynamic etc. support from gfortran -### stderr. +touch conftest1.$ac_objext conftest2.$ac_objext +LQUADMATH=-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="%{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="%{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="%{static-libquadmath:-aarchive_shared} -lquadmath %{static-libquadmath:-adefault}" +elif grep "conftest1.$ac_objext.* ligfortran.a .*conftest2.$ac_objext" \ s/ligfortran.a/libgfortran.a/ + conftest.cmd >/dev/null 2>&1; then + LQUADMATH="%{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" = xyes; then if test "x$USE_IEC_60559" = xyes; then - LIBQUADSPEC="$libgfor_cv_as_needed_option -lquadmath $libgfor_cv_no_as_needed_option" + LIBQUADSPEC="$libgfor_cv_as_needed_option $LQUADMATH $libgfor_cv_no_as_needed_option" else - 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} $LQUADMATH %{static-libgfortran:$libgfor_cv_no_as_needed_option}" fi else - LIBQUADSPEC="-lquadmath" + LIBQUADSPEC="$LQUADMATH" fi if test "x$USE_IEC_60559" != xyes; then if test -f ../libquadmath/libquadmath.la; then
[PATCH] fortran, v2: Add -static-libquadmath support [PR46539]
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. Thanks for catching that. > > --- 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)}\ > > s/static-libgfortran/static-libquadmath/ I guess? Otherwise I don’t > understand the corresponding ChangeLog description. Yeah. I just copied this part from the 2014 patch and didn't spot that. > > +elif grep "conftest1.$ac_objext.* -aarchive_shared -lgfortran > > -adefault .*conftest2.$ac_objext" \ > > + conftest.cmd >/dev/null 2>&1; then > > + LQUADMATH="%{static-libquadmath:-aarchive_shared} -lquadmath > > %{static-libquadmath:-adefault}" > > +elif grep "conftest1.$ac_objext.* ligfortran.a .*conftest2.$ac_objext" > > \ > > s/ligfortran.a/libgfortran.a/ 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. Here is an updated version (but nothing relevant to Linux changed, so there is no point for me to bootstrap/regtest it again): 2022-08-17 Francois-Xavier Coudert Jakub Jelinek 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): 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. --- 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. +static-libquadmath +Driver +; Documented for Fortran, but always accepted by driver. + static-libstdc++ Driver --- 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 = true; break; --- 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-outfile(-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.opt2022-08-16 14:52:52.459267705 +0200 @@ -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 s
Re: [Patch] Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566]
On Tue, Aug 16, 2022 at 04:45:07PM +0200, Tobias Burnus wrote: > Fixed subject line: "absent linear" should be "absent linear step" in the > subject line; > i.e. with "step" added: "Fortran: OpenMP fix declare simd inside modules and > absent linear step [PR106566]" > > I have also decided to move the 'step = 1' to openmp.cc, which also set it > before with > the old pre-OpenMP 5.2 syntax. > > I also added a pre-OpenMP-5.2-syntax example. > > * * * > > For GCC 12 (and GCC 11), only the '%s' fix and the third, now added example > apply; > for the 5.1 syntax, 'step' was already set. > > OK? And thoughts regarding the backports (none? Only 12? Or 11+12?)? > > Tobias > - > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 > München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas > Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht > München, HRB 106955 > Fortran: OpenMP fix declare simd inside modules and absent linear step > [PR106566] > > gcc/fortran/ChangeLog: > > PR fortran/106566 > * openmp.cc (gfc_match_omp_clauses): Fix setting linear-step value > to 1 when not specified. > (gfc_match_omp_declare_simd): Accept module procedures. > > gcc/testsuite/ChangeLog: > > PR fortran/106566 > * gfortran.dg/gomp/declare-simd-4.f90: New test. > * gfortran.dg/gomp/declare-simd-5.f90: New test. > * gfortran.dg/gomp/declare-simd-6.f90: New test. > > gcc/fortran/openmp.cc | 10 +++-- > gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 | 42 +++ > gcc/testsuite/gfortran.dg/gomp/declare-simd-5.f90 | 49 > +++ > gcc/testsuite/gfortran.dg/gomp/declare-simd-6.f90 | 42 +++ > 4 files changed, 140 insertions(+), 3 deletions(-) > > diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc > index a7eb6c3e8f4..594907714ff 100644 > --- a/gcc/fortran/openmp.cc > +++ b/gcc/fortran/openmp.cc > @@ -2480,7 +2480,7 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const > omp_mask mask, > goto error; > } > } > - else > + if (step == NULL) > { > step = gfc_get_constant_expr (BT_INTEGER, > gfc_default_integer_kind, Ah, didn't know that gfc_match ("%e ) ", &step) will free and clear step if it successfully matched it first and then doesn't match ) after it. So ok. > @@ -4213,9 +4213,13 @@ gfc_match_omp_declare_simd (void) >gfc_omp_declare_simd *ods; >bool needs_space = false; > > - switch (gfc_match (" ( %s ) ", &proc_name)) > + switch (gfc_match (" ( ")) > { > -case MATCH_YES: break; > +case MATCH_YES: > + if (gfc_match_symbol (&proc_name, /* host assoc = */ true) != MATCH_YES > + || gfc_match (" ) ") != MATCH_YES) > + return MATCH_ERROR; > + break; > case MATCH_NO: proc_name = NULL; needs_space = true; break; > case MATCH_ERROR: return MATCH_ERROR; > } LGTM. > diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 > b/gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 > new file mode 100644 > index 000..44132525963 > --- /dev/null > +++ b/gcc/testsuite/gfortran.dg/gomp/declare-simd-4.f90 > @@ -0,0 +1,42 @@ > +! { dg-do compile } > +! { dg-additional-options "-fdump-tree-gimple" } > +! > +! PR fortran/106566 > +! > +! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd > \\(linear\\(0:ref,step\\(4\\)\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } } > +! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd > \\(linear\\(0:ref,step\\(8\\)\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } } > + > +subroutine add_one2(p) > + implicit none > + !$omp declare simd(add_one2) linear(p: ref) simdlen(8) > + integer :: p Wonder if it wouldn't be better to use integer(kind=4) explicitly when you try to match the size of that multiplied by 1 or 2 in dg-final, as say with -fdefault-integer-8 this will fail miserably otherwise. Ditto in other spots in this as well as other tests. Ok with/without that change. As for backports, I'd wait some time with just trunk and then backport wherever you are willing to test it. Jakub
Re: [Patch] Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566]
On 17.08.22 15:09, Jakub Jelinek wrote: On Tue, Aug 16, 2022 at 04:45:07PM +0200, Tobias Burnus wrote: Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566] ... LGTM. +! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd \\(linear\\(0:ref,step\\(4\\)\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } } ... + integer :: p Wonder if it wouldn't be better to use integer(kind=4) explicitly when you try to match the size of that multiplied by 1 or 2 in dg-final, as say with -fdefault-integer-8 this will fail miserably otherwise. Ditto in other spots in this as well as other tests. I assume(d) that no one would compile with -fdefault-integer-8. But possibly it should be changed to permit testing with that flag, given that API routines should be able to handle different default-kind integers. On the other hand, API routines implies 'omp_lib', which is only available in libgomp/testsuite/. Ok with/without that change. Thanks for the review. Tobias - Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955