#define FORTRAN_LIBRARY "gfortran"
#endif
+#ifndef CAF_SHMEM_LIBRARY
+#define CAF_SHMEM_LIBRARY "caf_shmem"
+#endif
+
/* Name of the spec file. */
#define SPEC_FILE "libgfortran.spec"
/* Whether we need to link statically. */
int static_linking = 0;
+ /* Whether -fcoarray=shared was given; triggers auto-link of -lcaf_shmem. */
+ int need_caf_shmem = 0;
+
/* The number of input and output files in the incoming arg list. */
int n_infiles = 0;
int n_outfiles = 0;
++n_outfiles;
break;
+ case OPT_fcoarray_:
+ if (decoded_options[i].value == GFC_FCOARRAY_SHARED)
+ need_caf_shmem = 1;
+ break;
+
case OPT_v:
verbose = 1;
break;
saw_speclang = (strcmp (lang, "none") != 0);
}
+ /* -fcoarray=shared is a driver-level alias for -fcoarray=lib that
+ also arranges for -lcaf_shmem to be linked automatically. Pass
+ -fcoarray=lib to cc1 so the frontend uses the library code path. */
+ if (decoded_options[i].opt_index == OPT_fcoarray_
+ && decoded_options[i].value == GFC_FCOARRAY_SHARED)
+ {
+ append_option (OPT_fcoarray_, "lib", GFC_FCOARRAY_LIB);
+ continue;
+ }
+
append_arg (&decoded_options[i]);
continue;
default:
break;
}
+
+ if (need_caf_shmem)
+ append_option (OPT_l, CAF_SHMEM_LIBRARY, 1);
}
#ifdef ENABLE_SHARED_LIBGCC
fcoarray=
Fortran RejectNegative Joined Enum(gfc_fcoarray) Var(flag_coarray) Init(GFC_FCOARRAY_NONE)
--fcoarray=<none|single|lib> Specify which coarray parallelization should be used.
+-fcoarray=<none|single|lib|shared> Specify which coarray parallelization should be used.
Enum
Name(gfc_fcoarray) Type(enum gfc_fcoarray) UnknownError(Unrecognized option: %qs)
EnumValue
Enum(gfc_fcoarray) String(lib) Value(GFC_FCOARRAY_LIB)
+EnumValue
+Enum(gfc_fcoarray) String(shared) Value(GFC_FCOARRAY_SHARED)
+
fcheck=
Fortran RejectNegative JoinedOrMissing
-fcheck=[...] Specify which runtime checks are to be performed.
--- /dev/null
+! { dg-do link }
+! { dg-options "-fcoarray=shared -fdump-tree-original" }
+!
+! Test that -fcoarray=shared is accepted and generates the same
+! library-based CAF calls as -fcoarray=lib.
+
+program test
+ implicit none
+ integer :: x[*]
+ x = this_image ()
+ sync all
+end program test
+
+! { dg-final { scan-tree-dump-times "_gfortran_caf_init \\(&argc, &argv\\);" 1 "original" } }
+! { dg-final { scan-tree-dump-times "_gfortran_caf_sync_all \\(" 1 "original" } }