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

Jerry D <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
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

I adjusted the ChangeLog and changed the dg-do compilke to dg-do link.

Retested all.

Thanks for comment.

Jerry

Pending on approval.

--- snip ---

commit 0f7a6f628a6b9f09a663a064477da4d747a776a1 (HEAD -> master)
Author: Jerry DeLisle <[email protected]>
Date:   Sat May 9 11:49:21 2026 -0700

     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.


Addeed in the Assisted by words.


--- snip ---

diff --git a/gcc/testsuite/gfortran.dg/coarray_51.f90 
b/gcc/testsuite/gfortran.dg/coarray_51.f90
new file mode 100644
index 00000000000..da8a270c262
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray_51.f90
@@ -0,0 +1,15 @@
+! { dg-do link }
+! { dg-options "-fcoarray=shared -fdump-tree-original" }
+!
  --- snipped ---
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.