Re: [PATCH. fortran] Add automatic linking to caf_shmem using -fcoarray=shared

Paul Richard Thomas <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <CAGkQGi+ePtxS9UyEOy1SmcU6wTNhVxT-KUO3RficcDUQF5vhAA@mail.gmail.com>
Hi Jerry,

This does what it says on the box :-)

OK for mainline and backporting to 16-branch.

Regards

Paul

On Mon, 11 May 2026 at 00:26, Jerry D <[email protected]> wrote:
>
> On 5/9/26 2:12 PM, Andre Vehreschild wrote:
> > Hi Jerry,
> >
> > shouldn't that be dg-do link in testcase? Does dg-do compile also link?
> >
> > Regards,
> > Andre
> >
> > Andre Vehreschild
>
> See revised patch attached, ready for approval.
>
> OK for mainline and backport to 16?
>
> Regards,
>
> Jerry
> ---
>  From 0fb3be9df144dec1a0bba475ae8e64ac81df3586 Mon Sep 17 00:00:00 2001
> From: Jerry DeLisle <[email protected]>
> Date: Sat, 9 May 2026 11:49:21 -0700
> Subject: [PATCH] fortran: Add -fcoarray=shared option to auto-link -lcaf_shmem
>
> The new -fcoarray=shared option provides a convenient shorthand for
> the common invocation -fcoarray=lib -lcaf_shmem.  The driver transforms
> -fcoarray=shared into -fcoarray=lib for the frontend and automatically
> appends -lcaf_shmem to the link command.  Existing uses of -fcoarray=lib
> are unaffected.
>
> Assisted by: Claude Sonnet 4.6
>
> gcc/:
>
>         * flag-types.h (gfc_fcoarray): Add GFC_FCOARRAY_SHARED.
>
> gcc/fortran/:
>
>         * lang.opt (fcoarray=): Add shared enum value; update help text.
>         * gfortranspec.cc (CAF_SHMEM_LIBRARY): New macro.
>         (lang_specific_driver): Detect -fcoarray=shared in first pass and
>         set need_caf_shmem flag.  In second pass, transform -fcoarray=shared
>         to -fcoarray=lib for cc1.  Append -lcaf_shmem when need_caf_shmem
>         is set and linking is active.
>
> gcc/testsuite/:
>
>         * gfortran.dg/coarray_51.f90: New test.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.