is glibc c11 thread implementation a wrapper on top of pthread?

Viewed 352

to build a c11 thread program with glibc I still need link with -lpthread,why? glibc 2.28 claims c11 thread support but why I need pthread still?

musl can build c11 thread without pthread though.

1 Answers

Yes, glibc's C11 threads implementation is using pthreads library underneath and that's why it needs linking with pthread library. In glibc, pthreads is (was always) a separate library - thus the need to link it.

Whereas in musl library, the thread implementation is a part of the main C library itself and thus there's no need to link any thread library whether you use pthreads or C11 threads with musl. Also, see https://www.openwall.com/lists/musl/2012/07/25/3.

Related