In libgfortran/caf/shmem/thread_support.{h,c}, pthread.h is included only
when `!defined(WIN32) && !defined(__CYGWIN__)`. For Cygwin and MinGW hosts,
native named mutexes and semaphores are used and a pthread library is not
needed.

This commit overrides the result of the previous check for pthread, so
libcaf_shmem is always built for these hosts even when a pthread library
isn't available.

libgfortran/ChangeLog:

        * configure.ac: Set `enable_caf_shmem` to true for Cygwin and MinGW 
hosts.
        * configure: Regenerate.

Signed-off-by: LIU Hao <[email protected]>
---
 libgfortran/configure    | 3 +++
 libgfortran/configure.ac | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/libgfortran/configure b/libgfortran/configure
index e81d6d7c6d16..223ec82667c9 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -18480,6 +18480,9 @@ case ${host} in
     # These versions define PTHREAD_PROCESS_SHARED but the functionality
     # is not available at runtime, so the configure check misleads.
     enable_caf_shmem=false;;
+  *-*-cygwin* | *-*-mingw*)
+    # The specific implementation for these platforms does not use pthread.
+    enable_caf_shmem=true;;
 esac
  if test x$enable_caf_shmem = xtrue; then
   ENABLE_CAF_SHMEM_TRUE=
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index a63e1c4480c3..c50112df91c6 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -380,6 +380,9 @@ case ${host} in
     # These versions define PTHREAD_PROCESS_SHARED but the functionality
     # is not available at runtime, so the configure check misleads.
     enable_caf_shmem=false;;
+  *-*-cygwin* | *-*-mingw*)
+    # The specific implementation for these platforms does not use pthread.
+    enable_caf_shmem=true;;
 esac
 AM_CONDITIONAL([ENABLE_CAF_SHMEM], [test x$enable_caf_shmem = xtrue])
 -- 2.55.0

From 4113cd1a6ec00d4bb00ba4ee192b77a10b01222c Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Fri, 25 Sep 2026 16:50:32 +0800
Subject: [PATCH] libgfortran: Set `enable_caf_shmem` to true for Cygwin and
 MinGW hosts

In libgfortran/caf/shmem/thread_support.{h,c}, pthread.h is included only
when `!defined(WIN32) && !defined(__CYGWIN__)`. For Cygwin and MinGW hosts,
native named mutexes and semaphores are used and a pthread library is not
needed.

This commit overrides the result of the previous check for pthread, so
libcaf_shmem is always built for these hosts even when a pthread library
isn't available.

libgfortran/ChangeLog:

        * configure.ac: Set `enable_caf_shmem` to true for Cygwin and MinGW 
hosts.
        * configure: Regenerate.

Signed-off-by: LIU Hao <[email protected]>
---
 libgfortran/configure    | 3 +++
 libgfortran/configure.ac | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/libgfortran/configure b/libgfortran/configure
index e81d6d7c6d16..223ec82667c9 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -18480,6 +18480,9 @@ case ${host} in
     # These versions define PTHREAD_PROCESS_SHARED but the functionality
     # is not available at runtime, so the configure check misleads.
     enable_caf_shmem=false;;
+  *-*-cygwin* | *-*-mingw*)
+    # The specific implementation for these platforms does not use pthread.
+    enable_caf_shmem=true;;
 esac
  if test x$enable_caf_shmem = xtrue; then
   ENABLE_CAF_SHMEM_TRUE=
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index a63e1c4480c3..c50112df91c6 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -380,6 +380,9 @@ case ${host} in
     # These versions define PTHREAD_PROCESS_SHARED but the functionality
     # is not available at runtime, so the configure check misleads.
     enable_caf_shmem=false;;
+  *-*-cygwin* | *-*-mingw*)
+    # The specific implementation for these platforms does not use pthread.
+    enable_caf_shmem=true;;
 esac
 AM_CONDITIONAL([ENABLE_CAF_SHMEM], [test x$enable_caf_shmem = xtrue])
 
-- 
2.55.0

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to