https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90133
Bug ID: 90133 Summary: Linker error if no Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: damian at sourceryinstitute dot org Target Milestone: --- The code below compiles cleanly with -fcoarray=single but generates a linker error when I use -fcoarray=lib and link to MPICH and OpenCoarrays. The linking problem goes away if the "use" statement and "type(event_type)" declaration are moved to just after the "associate" statement and wrapped in "block/end block", which leads me to suspect this might be a gfortran bug rather than an OpenCoarrays bug. $ cat link-error.f90 module link_error contains subroutine post_event_in_associate use iso_fortran_env type(event_type), save :: e[*] associate( i => 1 ) event post(e[1]) end associate end end module end $ gfortran \ -I/home/rouson/Desktop/Builds/opt/opencoarrays/2.6.1-b480f1d/gnu/9.0.1/include/OpenCoarrays-2.6.1-14-gb480f1d_GNU-9.0.1 \ -fcoarray=lib \ -Wl,-rpath \ -Wl,/home/rouson/Builds/opt/mpich/3.2/gnu/9.0.1/lib \ -Wl,--enable-new-dtags ${@} \ /home/rouson/Desktop/Builds/opt/opencoarrays/2.6.1-b480f1d/gnu/9.0.1/lib/libcaf_mpi.a \ /home/rouson/Desktop/Builds/opt/mpich/3.2/gnu/9.0.1/lib/libmpifort.so \ /home/rouson/Desktop/Builds/opt/mpich/3.2/gnu/9.0.1/lib/libmpi.so \ link-error.f90 /tmp/ccU8ZmCw.o: In function `_caf_init.1.3907': link-error.f90:(.text+0x4d): undefined reference to `caf_token.0.3905' link-error.f90:(.text+0x5c): undefined reference to `_gfortran_caf_register' /tmp/ccU8ZmCw.o: In function `__link_error_MOD_post_event_in_associate': link-error.f90:(.text+0x8b): undefined reference to `caf_token.0.3905' link-error.f90:(.text+0xae): undefined reference to `_gfortran_caf_event_post' /tmp/ccU8ZmCw.o: In function `main': link-error.f90:(.text+0xda): undefined reference to `_gfortran_caf_init' link-error.f90:(.text+0x104): undefined reference to `_gfortran_caf_finalize' collect2: error: ld returned 1 exit status $ gfortran --version GNU Fortran (GCC) 9.0.1 20190318 (experimental)