Fortran: Make caf_shmem build pthread presence aware.

On some system pthreads needs special treatment.  Use the present
AX_PTHREADS macro to figure what is needed.

libgfortran/ChangeLog:

	* Makefile.am: Only build caf_shmem when pthreads is available.
	* configure.ac: Check for pthreads availability and needed
	flags.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/caf.exp: Only add caf_shmem to tests when
	is build.
This commit is contained in:
Andre Vehreschild
2026-02-18 10:14:58 +01:00
committed by Jerry DeLisle
parent 4cfa7717f2
commit ea75839204
3 changed files with 27 additions and 6 deletions

View File

@@ -29,6 +29,7 @@
# Load procedures from common libraries.
load_lib gfortran-dg.exp
load_lib atomic-dg.exp
load_lib target-libpath.exp
# If a testcase doesn't have special options, use these.
global DEFAULT_FFLAGS
@@ -48,6 +49,11 @@ global gfortran_test_path
global gfortran_aux_module_flags
set gfortran_test_path $srcdir/$subdir
set gfortran_aux_module_flags $DEFAULT_FFLAGS
global enable_caf_shmem
set gccpath [get_multilibs]
set shlib_ext [get_shlib_extension]
set enable_caf_shmem [expr [file exists "${gccpath}/libgfortran/.libs/libcaf_shmem.a"] || \
[file exists "${gccpath}/libgfortran/.libs/libcaf_shmem.${shlib_ext}"] ]
proc dg-compile-aux-modules { args } {
global gfortran_test_path
@@ -110,11 +116,13 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]]
cleanup-modules ""
}
foreach flags $option_list {
verbose "Testing $nshort (libcaf_shmem), $flags" 1
set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_shmem"
dg-test $test "-fcoarray=lib $flags -lcaf_shmem" {}
cleanup-modules ""
if "$enable_caf_shmem" {
foreach flags $option_list {
verbose "Testing $nshort (libcaf_shmem), $flags" 1
set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_shmem"
dg-test $test "-fcoarray=lib $flags -lcaf_shmem" {}
cleanup-modules ""
}
}
}
torture-finish

View File

@@ -68,6 +68,8 @@ libcaf_single_la_LDFLAGS = -static
libcaf_single_la_DEPENDENCIES = $(libcaf_shared_DEPS)
libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
if ENABLE_CAF_SHMEM
libcaf_shmem_la_CFLAGS = $(CAF_SHMEM_CFLAGS)
libcaf_shmem_la_SOURCES = $(libcaf_shared_SRCS) \
caf/shmem.c caf/shmem/alloc.c caf/shmem/allocator.c \
caf/shmem/collective_subroutine.c caf/shmem/counter_barrier.c \
@@ -80,7 +82,8 @@ libcaf_shmem_la_DEPENDENCIES = $(libcaf_shared_DEPS) caf/shmem/alloc.h \
caf/shmem/counter_barrier.h caf/shmem/hashmap.h \
caf/shmem/shared_memory.h caf/shmem/supervisor.h caf/shmem/sync.h \
caf/shmem/teams_mgmt.h caf/shmem/thread_support.h
libcaf_shmem_la_LINK = $(LINK) $(libcaf_shmem_la_LDFLAGS)
libcaf_shmem_la_LINK = $(LINK) $(libcaf_shmem_la_LDFLAGS) $(CAF_SHMEM_LIBS)
endif
if IEEE_SUPPORT
fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude

View File

@@ -343,6 +343,16 @@ else
freelocale uselocale strerror_l strtof128 strfromf128)
fi
# Check for existing and usable pthreads.
AX_PTHREAD([
enable_caf_shmem=true
CAF_SHMEM_CFLAGS="$PTHREAD_CFLAGS"
CAF_SHMEM_LIBS="$PTHREAD_LIBS"
], [
enable_caf_shmem=false
])
AM_CONDITIONAL([ENABLE_CAF_SHMEM], [test x$enable_caf_shmem = xtrue])
# Check strerror_r, cannot be above as versions with two and three arguments exist
LIBGFOR_CHECK_STRERROR_R