https://gcc.gnu.org/g:ee7d0c7b4102b8ef0bcaa725c75e141248b774cb
commit r17-1234-gee7d0c7b4102b8ef0bcaa725c75e141248b774cb Author: Jerry DeLisle <[email protected]> Date: Wed May 27 09:24:26 2026 -0700 fortran: also link -lpthread when -fcoarray=shared is used [PR125324] When the driver auto-links -lcaf_shmem for -fcoarray=shared it must also link -lpthread because the shmem CAF runtime uses POSIX threads internally. Assisted by: Claude Sonnet 4.6 PR fortran/125324 gcc/fortran/ChangeLog: * gfortranspec.cc (lang_specific_driver): Also append -lpthread when need_caf_shmem is set. (cherry picked from commit 8e2b89e87d195409ba1690e2f732431dc4b7305e) Diff: --- gcc/fortran/gfortranspec.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/gfortranspec.cc b/gcc/fortran/gfortranspec.cc index 13b240013e8a..a98c538889eb 100644 --- a/gcc/fortran/gfortranspec.cc +++ b/gcc/fortran/gfortranspec.cc @@ -428,7 +428,10 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" } if (need_caf_shmem) - append_option (OPT_l, CAF_SHMEM_LIBRARY, 1); + { + append_option (OPT_l, CAF_SHMEM_LIBRARY, 1); + append_option (OPT_l, "pthread", 1); + } } #ifdef ENABLE_SHARED_LIBGCC
