In the CI for grep and sed [1][2], I'm seeing this build error:

...
  CC       test-pthread-mutex.o
  CCLD     test-pthread-mutex
/usr/bin/ld: cannot find @LIB_SEMAPHORE@: No such file or directory
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:5613: test-pthread-mutex] Error 1

The cause is that LIB_SEMAPHORE is used (and is needed because
the test programs include atomic-int-posix.h), but gl_SEMAPHORE is
not being invoked.

Similarly, HAVE_SEMAPHORE_H is used (again because the test programs
include atomic-int-posix.h), but AC_CHECK_HEADERS_ONCE([semaphore.h])
is missing.

This patch should fix it.

[1] https://github.com/gnu-grep/ci-check/actions/runs/9344481782
[2] https://github.com/gnu-sed/ci-check/actions/runs/9344732180


2024-06-03  Bruno Haible  <br...@clisp.org>

        pthread-mutex, pthread-rwlock: Fix a compilation error.
        * modules/pthread-mutex-tests (Files): Add m4/semaphore.m4.
        (configure.ac): Check for semaphore.h. Require gl_SEMAPHORE.
        * modules/pthread-rwlock-tests (Files): Add m4/semaphore.m4.
        (configure.ac): Check for semaphore.h. Require gl_SEMAPHORE.

diff --git a/modules/pthread-mutex-tests b/modules/pthread-mutex-tests
index 9475a84a99..cc234afc77 100644
--- a/modules/pthread-mutex-tests
+++ b/modules/pthread-mutex-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-pthread-mutex.c
 tests/atomic-int-posix.h
 tests/macros.h
+m4/semaphore.m4
 
 Depends-on:
 pthread-thread
@@ -9,6 +10,8 @@ sched_yield
 random
 
 configure.ac:
+AC_CHECK_HEADERS_ONCE([semaphore.h])
+AC_REQUIRE([gl_SEMAPHORE])
 
 Makefile.am:
 TESTS += test-pthread-mutex
diff --git a/modules/pthread-rwlock-tests b/modules/pthread-rwlock-tests
index 129570b67d..b63a267876 100644
--- a/modules/pthread-rwlock-tests
+++ b/modules/pthread-rwlock-tests
@@ -2,6 +2,7 @@ Files:
 tests/test-pthread-rwlock.c
 tests/atomic-int-posix.h
 tests/macros.h
+m4/semaphore.m4
 
 Depends-on:
 pthread-thread
@@ -10,6 +11,8 @@ sched_yield
 random
 
 configure.ac:
+AC_CHECK_HEADERS_ONCE([semaphore.h])
+AC_REQUIRE([gl_SEMAPHORE])
 
 Makefile.am:
 TESTS += test-pthread-rwlock




Reply via email to