For backwards compatibility, many Linux distributions support both the older LinuxThreads implementation as well as the newer Native POSIX Thread Library (NPTL). By setting the LD_ASSUME_KERNEL environment variable you can tell the dynamic linker to assume that it is running on top of a particular kernel version. This will override the dynamic linker’s default choice of threading implementation (usually NPTL) and force the use of the older LinuxThreads implementation at run-time.
Many 32-bit systems have 3 separate glibc versions which have support for a minimum OS Application Binary Interface (ABI), designated by a kernel version and offer support for a particular thread implementation.
/lib/tls/libc.so.6
- minimum ABI = 2.4.20
- Native POSIX Thread Library (NPTL)
/lib/i686/libc.so.6
- minimum ABI = 2.4.1
- standard LinuxThreads
/lib/libc.so.6
- minimum ABI = 2.2.5
- early LinuxThreads code which had fixed size threads
It is worth noting that 64-bit systems do not support the older 2.2.5 LinuxThreads implementation.
You can run the following commands to see what thread implementations are supported by each separate glibc library.
$ /lib/tls/libc.so.6 | grep [T|t]hreads
Native POSIX Threads Library by Ulrich Drepper
$ /lib/i686/libc.so.6 | grep [T|t]hreads
linuxthreads-0.10 by Xavier Leroy
$ /lib/libc.so.6 | grep [T|t]hreads
linuxthreads-0.10 by Xavier Leroy
A shared library can tell the dynamic linker which minimum OS ABI version is needed for it to successfully run. At run-time the linker will start at the most recent library path and walk backwards in this order: /lib/tls, /lib/i686, /lib. It will either link to the first library it finds or fail and terminate the program if the minimum ABI is reached before it finds a library.
Setting LD_ASSUME_KERNEL below the minimum threshold ABI version of any dynamic library will cause the linker to skip that library and try to find an older implementation
Set the environment variable by assigning it to a specific ABI/kernel version.
$ export LD_ASSUME_KERNEL=X.Y.Z
You must be careful not to set the the ABI below 2.2.5 in your environment as all programs which require dynamic linking will probably fail to run. Luckily you are still be able to unset or change it back.
It is useless to set LD_ASSUME_KERNEL for most programs as they will run correctly no matter what underlying implementation is used since the API is the same. However there are some programs that may depend on some non-conformant behavior requiring LinuxThreads, which will fail with NPTL.