]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Add -fcoarray=shared option to auto-link -lcaf_shmem
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Sat, 9 May 2026 18:49:21 +0000 (11:49 -0700)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Mon, 11 May 2026 16:23:46 +0000 (09:23 -0700)
commitbe1da01067c898a3e3979bfb1edd05f115ab2e3e
tree9d4f7742a28abd04493a94dd063cb5dedbbdcb37
parent061949be51776e80d704e507c980b750c90aa5f2
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.
gcc/flag-types.h
gcc/fortran/gfortranspec.cc
gcc/fortran/lang.opt
gcc/testsuite/gfortran.dg/coarray_51.f90 [new file with mode: 0644]