HOWTO Migrate to NPTL

From Gentoo Linux Wiki

Jump to: navigation, search


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc
Warning: This HOWTO is outdated since 2006.1 as NPTL is the only alternative with 2006.1 and later

Contents

[edit] What is NPTL?

Native POSIX Thread Library (NPTL) is a thread library which is, unlike previous attempts, a very thin layer on top of the kernel. This helps to achieve a maximum of performance for a minimal price. It is intended as a replacement of the old linuxthreads library. The major benefit of NPTL over linuxthreads from a users perspective is that it's faster (refer to the PDF for benchmarks). For programmers it has the added benefit of being more posix compliant, as the name suggests.

[edit] Using NPTL

Besides that NPTL also provides signal handling on a per thread basis rather than per process, also now with NPTL support you can send the arguments with the signals.

[edit] Switching to NPTL

It is also possible to switch to NPTL on a pre-configured Gentoo system. This previously required you to unmerge linux-headers and emerge linux26-headers, where-as now you only need to make sure you have linux-headers-2.6.* installed. As mentioned above, a 2.6 kernel is required. I have assumed here that the system was already running a kernel from this series. The steps involved are:

Add the nptl and nptlonly flags to /etc/make.conf in its USE line, then run:

emerge --newuse world
Warning: nptlonly may cause problems. If you don't know what you are doing, do not set this flag.

If emerge doesn't want to rebuild anything, you might be using a Profile with NPTL (e.g. x86-default 2006.0). In this case, you're already done, but to be sure check:

USE="nptl" emerge -pv glibc

If that reveals that it refuses to accept your nptl use flag like in the following output:

Calculating dependencies... done!
[ebuild   R   ] sys-libs/glibc-2.5-r4  USE="nls -build -debug -glibc-compat20 -glibc-omitfp (-hardened) (-multilib) (-nptl) (-nptlonly) -profile (-selinux)" 0 kB

then you probably still use an old non-NPTL profile, so in this case check:

eselect profile show

and switch to a recent profile if this is in fact the case.

After rebooting you should have NPTL fully operational and running. You can verify the threading model used by libc by typing:

Code: Verify NPTL
/lib/libc.so.6

or, if you did not specify nptlonly:

/lib/tls/libc.so.6

Your output should read:

Code: Libc.so.6 Output
GNU C Library 20041102 release version 2.3.4, by Roland McGrath et al.
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7).
Compiled on a Linux 2.6.8 system on 2004-12-21.
Available extensions:
       GNU libio by Per Bothner
       crypt add-on version 2.1 by Michael Glad and others
       Native POSIX Threads Library by Ulrich Drepper et al
       The C stubs add-on version 2.1.2.
       GNU Libidn by Simon Josefsson
       BIND-8.2.3-T5B
       NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

Note: You may also need to re-emerge nvidia-glx if XMMS, MPlayer or X11 segfault.

If XMMS complains of ld.so inconsistency, re-emerge flac

[edit] Notes

[edit] Additional Information

According to this post [fixed 404 error] (here's the archive.org post) - You do not need to be running a 2.6 kernel to compile glibc with NPTL support. Of course with a vanilla 2.4 kernel you won't actually be able to use NPTL, that will require a kernel that has NPTL backported.

The following post is interesting too.

[edit] Common Mistakes

If emerging libc aborts with the following error: the virtual/os-headers package conflicts with another package. both can't be installed on the same system together (this refers to sys-kernel/linux-headers and linux26-headers-*) Be careful, linux26-headers has been renamed linux-headers as the Linux 2.6 kernel is now the default Gentoo kernel. Don't unmerge linux-headers!

Make sure your CHOST from /etc/make.conf is correct; if it is i386, nptl support won't be built.

Question: What machine types are supported? i686 only??? What about i386, i486, and the multitude of other architectures?
Answer: NPTL works great on my ppc and amd64 systems. On x86 you need to use i486 or later.

[edit] FAQ

  • Will I be able to remove NPTL and re-emerge glibc without it? : Yes. There has been no noted side effects of removing NPTL.
  • Will it work with GCC 3.4? : Yes. NPTL fully supports GCC 3.4.
  • What are packages that use NPTL other than glibc? : Ximian OpenOffice, Wine and Mono are currently the ones I have come across. I suggest you run emerge --newuse world after switching to NPTL to re-emerge packages with the updated USE Flags.
  • Do I need to recompile everything (emerge -e world) after switching to NPTL? : Nope, just emerge --newuse -p world and that should take care of everything. You can probably compare nptl to arts USE flag; It adds that feature to the packages which support it.
  • Will nptlonly break previously compiled packages that still use linuxthreads? : So far I've seen no reports of this happening, so I guess the answer would be 'no'.
  • Are there any other problems with NPTL I should know about?
    • Yes, some java-based applications might not work if you re-emerge world with the nptlonly flag. See [1].
    • Several users reported segmentation faults in various applications. Most of them are based on Mozilla.
Personal tools
In other languages