libraries, pthread cleanup, remove libthr support

Hal Murray hmurray at megapathdsl.net
Sun Jan 27 06:05:22 UTC 2019


I'd like to get rid of wafhelpers/check_pthread.py

There may have been some PTHREAD conditionals in our code ages ago, but they 
are all gone.

The main thing check_pthread is doing is setting up to use libthr rather than 
libpthread.

FreeBSD uses libthr.so rather than libpthread.so.  But it has links, so asking 
for -libpthread works but ldd will show libthr.so

lrwxr-xr-x  1 root  wheel  10 Dec  6 20:12 /usr/lib/libpthread_p.a -> 
libthr_p.a
lrwxr-xr-x  1 root  wheel   9 Dec  6 20:12 /usr/lib/libpthread.so -> libthr.so
lrwxr-xr-x  1 root  wheel   8 Dec  6 20:12 /usr/lib/libpthread.a -> libthr.a

So FreeBSD works without anything special.


The other interesting case that I can test locally is musl on Alpine Linux.  It doesn't have libpthred.so, but does have 
-rw-r--r--    1 root     root             8 Jun 19  2018 /usr/lib/libpthread.a
alp:~$ cat /usr/lib/libpthread.a
!<arch>
alp:~$ 

I assume that is a flag for some magic, but I haven't tracked it down.  Linking with -lpthread seems to get folded into musl:
alp:~$ ldd /usr/local/sbin/ntpd
        /lib/ld-musl-x86_64.so.1 (0x7957db6bc000)
        libcrypto.so.1.0.0 => /lib/libcrypto.so.1.0.0 (0x7957db051000)
        libcap.so.2 => /usr/lib/libcap.so.2 (0x7957dae4c000)
        libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7957dac3a000)
        libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7957db6bc000)
        libz.so.1 => /lib/libz.so.1 (0x7957daa23000)
alp:~$ 

In hindsight, it seems reasonable to expect -lpthread and friends (eg -lm and -lrt) to work, one way or the other.  Not having that would be a huge pain in the ass when porting code.

Their man pages are normal Linux pages.

Any reason not to push this?

--------

Why is -lrt optional?
    ctx.check_cc(lib="rt", mandatory=False, comment="realtime library")

We need it for timers: timer_create, timer_settime, and timer_gettime.

Do POSIX specs include the library?

Even if the actual code is in libc, I'd expect most system would have a dummy librt just to help portability.

---------

What's the advantage of checking for a library via pkg-config?  waf ctx.check_cfg vs ctx.check_cc?

We use it for libcrypto and libseccomp, with a fallback to the simple version.

--------

This doesn't solve the -pthread vs -lpthread tangle.


-- 
These are my opinions.  I hate spam.





More information about the devel mailing list