A consumer may want to avoid -lpthread dependency if thread ID is not critical e.g., only used for tracing/debugging. Example: https://github.com/freebsd/freebsd-ports/blob/d1e16f7b264b/multimedia/libva/files/patch-va_va__trace.c Environment: $ cat a.c #include <stdio.h> #include <pthread_np.h> int main() { printf("%d\n", pthread_getthreadid_np()); return 0; } FreeBSD: $ cc a.c ld: error: undefined symbol: pthread_getthreadid_np >>> referenced by a.c >>> /tmp/a-104ade.o:(main) cc: error: linker command failed with exit code 1 (use -v to see invocation) $ cc a.c -pthread $ ./a.out 101610 DragonFly: $ cc a.c $ ./a.out 0 $ cc a.c -pthread $ ./a.out 1
A commit references this bug: Author: kib Date: Sun Jun 23 10:50:27 UTC 2019 New revision: 349299 URL: https://svnweb.freebsd.org/changeset/base/349299 Log: Add libc stub for pthread_getthreadid_np(3). Requested by: jbeich PR: 238650 Sponsored by: The FreeBSD Foundation MFC after: 1 week Changes: head/lib/libc/gen/Symbol.map head/lib/libc/gen/_pthread_stubs.c head/lib/libc/include/libc_private.h head/lib/libthr/thread/thr_init.c
A commit references this bug: Author: kib Date: Wed Jul 3 19:24:52 UTC 2019 New revision: 349679 URL: https://svnweb.freebsd.org/changeset/base/349679 Log: MFC r349299: Add libc stub for pthread_getthreadid_np(3). PR: 238650 Changes: _U stable/12/ stable/12/lib/libc/gen/Symbol.map stable/12/lib/libc/gen/_pthread_stubs.c stable/12/lib/libc/include/libc_private.h stable/12/lib/libthr/thread/thr_init.c
A commit references this bug: Author: kib Date: Wed Jul 3 19:42:37 UTC 2019 New revision: 349688 URL: https://svnweb.freebsd.org/changeset/base/349688 Log: MFC r349299: Add libc stub for pthread_getthreadid_np(3). PR: 238650 Changes: _U stable/11/ stable/11/lib/libc/gen/Symbol.map stable/11/lib/libc/gen/_pthread_stubs.c stable/11/lib/libc/include/libc_private.h stable/11/lib/libthr/thread/thr_init.c
Committed and MFCed.
A commit references this bug: Author: jbeich Date: Wed Jul 10 01:16:14 UTC 2019 New revision: 506329 URL: https://svnweb.freebsd.org/changeset/ports/506329 Log: multimedia/libva: drop -lpthread on FreeBSD 11.4/12.1/13.0 libva doesn't use threads unless LIBVA_TRACE is passed via environment. PR: 238650 Changes: head/multimedia/libva/Makefile