link error in tests on NetBSD
Closed, ResolvedPublic

Description

The build of npth-1.3 fails on NetBSD with:

  • t-mutex --- libtool: link: gcc -O2 -g -fPIC -D_FORTIFY_SOURCE=2 -Wl,-z

-Wl,relro -Wl,-z -Wl,now -Wl,-rpath -Wl,/usr/pkg/lib -o .libs/t-mutex t-mutex.o
-L../src/.libs -lnpth -Wl,-rpath,/usr/pkg/lib

                            
../src/.libs/libnpth.so:

undefined reference to `sem_wait'

../src/.libs/libnpth.so: undefined reference to `sem_init'

                                                                
../src/.libs/libnpth.so: undefined reference to `pthread_create'
                                                                
               ../src/.libs/libnpth.so: undefined reference to

`sem_open'

../src/.libs/libnpth.so:

undefined reference to `sem_post'

  • t-fork
  • ../src/.libs/libnpth.so: undefined reference to sem_wait' ../src/.libs/libnpth.so: undefined reference to sem_init' ../src/.libs/libnpth.so: undefined reference

to `pthread_create'

../src/.libs/libnpth.so: undefined reference to `sem_open'
../src/.libs/libnpth.so: undefined reference to `sem_post'

and

  • t-thread ---

libtool: link: gcc -O2 -g -fPIC -D_FORTIFY_SOURCE=2 -Wl,-z -Wl,relro -Wl,-z
-Wl,now -Wl,-rpath -Wl,/usr/pkg/lib -o .libs/t-thread t-thread.o -L../src/.libs
-lnpth -Wl,-rpath,
/usr/pkg/lib
t-thread.o: In function `main':
/scratch/devel/npth/work/npth-1.3/tests/t-thread.c:127: undefined reference to
`pthread_attr_init'
/scratch/devel/npth/work/npth-1.3/tests/t-thread.c:129: undefined reference to
`pthread_attr_getdetachstate'
/scratch/devel/npth/work/npth-1.3/tests/t-thread.c:144: undefined reference to
`pthread_attr_destroy'
../src/.libs/libnpth.so: undefined reference to `sem_wait'
../src/.libs/libnpth.so: undefined reference to `sem_init'
../src/.libs/libnpth.so: undefined reference to `pthread_create'
../src/.libs/libnpth.so: undefined reference to `sem_open'
../src/.libs/libnpth.so: undefined reference to `sem_post'

  • [t-thread] Error code 1

Adding "-pthread" to the CFLAGS fixes it. It would be great if this could be
automatically detected and added.

Details

Version
1.3
wiz set Version to 1.3.Mar 16 2017, 4:07 PM
wiz added projects: npth, Bug Report.
wiz added a subscriber: wiz.
werner added a subscriber: werner.Mar 22 2017, 12:37 PM

gniibe: Do you have time to look into this?

werner assigned this task to gniibe.Mar 22 2017, 12:37 PM
werner added a subscriber: gniibe.

Our jenkins has no problems building nPth for OpenBSD 6.0.
wiz: Do you think that NetBSD (x86 I assume) is much different than OpenBSD so
that we would benefit from adding NetBSD to our Jenkins builds?

wiz added a comment.Mar 22 2017, 12:49 PM

NetBSD has its own pthread library (different from OpenBSD and FreeBSD), so I
think this would be a good idea.

Oh yes, then we should include NetBSD at least into the nPth and libgpg-error
builds.

It seems that -lrt is required on NetBSD.

I think that NetBSD also defines single thread version of pthread_* functions in
libc.
How about attached patch in configure.ac?
(You need to generate configure)

gniibe added a comment.Apr 5 2017, 4:51 AM

I tested with NetBSD 7.1 and -lrt is not required.
Nevertheless, it would be required for older NetBSD, so I leave -lrt check for NetBSD.
I'm going to push the change of D415 now.

gniibe lowered the priority of this task from High to Normal.Apr 5 2017, 4:52 AM

It works for me on NetBSD 7.1. Please test.

wiz added a comment.Apr 5 2017, 2:06 PM

Thanks for working on this.
I can't seem to find a link to the repository for testing, can you please point me in the right direction?

werner added a comment.Apr 5 2017, 3:00 PM

git://git.gnupg.org/npth.git

wiz added a comment.Apr 5 2017, 3:05 PM

Thank you. I just tried:

autoreconf -fiv && ./configure && make && make check
...
Making check in src
Making check in tests
make  check-TESTS
PASS: t-mutex
PASS: t-thread
PASS: t-fork
==================
All 3 tests passed
==================

on NetBSD-7.99.67/amd64.

Since you mentioned sem_init before, here's what configure reports about it:

checking for library containing sem_init... none required

Looks good, thank you!

Err... npth repo is not yet added under dev.gnupg.org.
I requested as T3064.

gniibe closed this task as Resolved.May 23 2017, 7:46 AM

Fixed in npth 1.4.