Discussion:
pthread related build error on CentOS 6
(too old to reply)
Tom G. Christensen
2017-01-26 20:15:43 UTC
Permalink
Raw Message
Hello,

My daily full gnulib bootstrap on CentOS 6 has stopped working with this
build error:
gcc -std=gnu99 -fvisibility=hidden -g -O2 -Wall -o git-merge-changelog
git-merge-changelog.o libgnu.a -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
libgnu.a(lock.o): In function `glthread_rwlock_init_for_glibc':
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:46: undefined
reference to `pthread_rwlockattr_init'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:53: undefined
reference to `pthread_rwlockattr_setkind_np'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:59: undefined
reference to `pthread_rwlockattr_destroy'
collect2: ld returned 1 exit status
make[4]: *** [git-merge-changelog] Error 1

Adding -pthread or -lpthread allows the link to succeed.

The build then fails again at:
gcc -std=gnu99 -g -O2 -Wall -o test-fstrcmp test-fstrcmp.o
../gllib/libgnu.a -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
../gllib/libgnu.a(lock.o): In function `glthread_rwlock_init_for_glibc':
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:46: undefined
reference to `pthread_rwlockattr_init'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:53: undefined
reference to `pthread_rwlockattr_setkind_np'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:59: undefined
reference to `pthread_rwlockattr_destroy'
collect2: ld returned 1 exit status
make[4]: *** [test-fstrcmp] Error 1

Manually linking test-fstrcmp with -pthread then allows the build to
complete.

-tgc
Tom G. Christensen
2017-01-31 08:49:57 UTC
Permalink
Raw Message
Post by Tom G. Christensen
Hello,
My daily full gnulib bootstrap on CentOS 6 has stopped working with this
gcc -std=gnu99 -fvisibility=hidden -g -O2 -Wall -o git-merge-changelog
git-merge-changelog.o libgnu.a -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:46: undefined
reference to `pthread_rwlockattr_init'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:53: undefined
reference to `pthread_rwlockattr_setkind_np'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:59: undefined
reference to `pthread_rwlockattr_destroy'
collect2: ld returned 1 exit status
make[4]: *** [git-merge-changelog] Error 1
Adding -pthread or -lpthread allows the link to succeed.
gcc -std=gnu99 -g -O2 -Wall -o test-fstrcmp test-fstrcmp.o
../gllib/libgnu.a -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:46: undefined
reference to `pthread_rwlockattr_init'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:53: undefined
reference to `pthread_rwlockattr_setkind_np'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:59: undefined
reference to `pthread_rwlockattr_destroy'
collect2: ld returned 1 exit status
make[4]: *** [test-fstrcmp] Error 1
Manually linking test-fstrcmp with -pthread then allows the build to
complete.
bump?

It's currently not possible for me to build a gnulib snapshot made with
this gnulib-tool invocation:
./gnulib-tool --create-testdir --with-tests
--dir=/home/tgc/projects/gnulib/build
--avoid=non-recursive-gnulib-prefix-hack

It will fail as shown above.

I've uploaded a log from a failed build:
http://jupiterrise.com/tmp/log-gnulib-201701301327195863188.txt
(add .gz for a compressed version)

-tgc
Bruno Haible
2017-01-31 23:16:56 UTC
Permalink
Raw Message
Hi Tom,
Post by Tom G. Christensen
gcc -std=gnu99 -g -O2 -Wall -o test-fstrcmp test-fstrcmp.o
../gllib/libgnu.a -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm -lm
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:46: undefined
reference to `pthread_rwlockattr_init'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:53: undefined
reference to `pthread_rwlockattr_setkind_np'
/home/tgc/projects/gnulib/build/gllib/glthread/lock.c:59: undefined
reference to `pthread_rwlockattr_destroy'
collect2: ld returned 1 exit status
make[4]: *** [test-fstrcmp] Error 1
Manually linking test-fstrcmp with -pthread then allows the build to
complete.
Thanks for the report. Fixed as follows:


2017-01-31 Bruno Haible <***@clisp.org>

lock: Fix link error (regression from 2017-01-05).
* lib/glthread/lock.h [USE_POSIX_THREADS_WEAK]: Declare also
pthread_rwlockattr_init, pthread_rwlockattr_setkind_np,
pthread_rwlockattr_destroy weak.
Reported by Tom G. Christensen <***@jupiterrise.com>.

diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h
index 69f6e31..ec16d39 100644
--- a/lib/glthread/lock.h
+++ b/lib/glthread/lock.h
@@ -139,6 +139,9 @@ extern int glthread_in_use (void);
# pragma weak pthread_mutexattr_init
# pragma weak pthread_mutexattr_settype
# pragma weak pthread_mutexattr_destroy
+# pragma weak pthread_rwlockattr_init
+# pragma weak pthread_rwlockattr_setkind_np
+# pragma weak pthread_rwlockattr_destroy
# ifndef pthread_self
# pragma weak pthread_self
# endif
Post by Tom G. Christensen
bump?
Sure I understood it's a blocker, but it took me two attempts to find the right
solution.

Bruno
Tom G. Christensen
2017-02-01 07:01:42 UTC
Permalink
Raw Message
Post by Bruno Haible
lock: Fix link error (regression from 2017-01-05).
* lib/glthread/lock.h [USE_POSIX_THREADS_WEAK]: Declare also
pthread_rwlockattr_init, pthread_rwlockattr_setkind_np,
pthread_rwlockattr_destroy weak.
Thank you!
Post by Bruno Haible
Sure I understood it's a blocker, but it took me two attempts to find the right
solution.
I'm sorry if I came across as impatient that was certainly not the
intention.

-tgc

Loading...