TITLE: Native POSIX Threading Library (NPTL) LFS VERSION: 5.0+ (PLFS) AUTHOR: Zack Winkles SYNOPSIS: This hint covers how to install the Native POSIX Threading Library by Ulrich Drepper, an alternative to linuxthreads. HINT: Contents ======== 1. Introduction 2. Prerequisites 3. Inline Installation 4. Feedback Changelog ========= * 0.2 - 20030411 - Initial release of rewrite. * 0.3 - 20030418 - Added patch for 2.4.20 futex support. * 0.4 - 20030421 - Backed out futex patch. General cleanups. * 0.5 - 20030421 - Added note about module-init-tools (Thanks DJ Lucas). Added warning about NVIDIA. * 0.6 - 20030423 - Moved to GCC 3.3 * 0.7 - 20030424 - NVIDIA_GLX works now. * 0.8 - 20030426 - Devfs notes. Patch to make 2.4.20 work w/ NPTL (Thanks YuX). * 0.9 - 20030505 - Added fix to allow building against old hosts. Added patch to fix detection of eh_frame using coreutils. Added note about rml's procps. * 0.10 - 20030506 - Oops. Forgot to put up the location of the GCC patch. * 0.11 - 20030512 - Another rewrite. LFS has moved to PLFS. Don't disable fixincl as it breaks GCC on old hosts. Removed 2.4 patch. Removed any remants of NVIDIA. * 0.12 - 20030515 - Futexes have been made optional in the latest kernel. make sure the user enables it. Update text for GCC 3.3. * 0.13 - 20030519 - Clarify warning about futexes. Introduction ============ The Native POSIX Threading Library is a relatively new threading library designed to replace the linuxthreads package in Glibc. It has many advantages over the linuxthreads package, one of which is the focus on standards-compliance. NPTL never sarcrifices standards-compliance under any circumstances, no matter the gains. Despite this, NPTL has world-class performance, with thread-spawning speeds as much as 500x the speed of traditional thread libs. Despite all these changes, it maintains near-complete backwards-compatibility with linuxthreads, and generally works perfectly as a drop-in replacement where the proper compiler infrastructure is already present. Prerequisites ============= 1. A kernel with proper support for thread-local storage. This means that you must use a fairly recent development (2.5) kernel. Be aware that the 2.5 series is maturing at a fairly high rate, and a large majority of the major changes have already happened, it's all a matter of stablizing what's there. To use a kernel greater than version 2.5.47 (*HIGHLY* recommended), you must use the new module handling package called module-init-tools. It comes with a very comprehensive README, so I won't go into any details here. ftp://ftp.kernel.org/pub/linux/kernel/people/rusty/modules/ It is imperative that you enable futexes in your kernel. The very recent kernels have made the building of futexes optional, but it is required for NPTL to function. 2. A recent CVS tarball of Glibc. This is required because NPTL uses features of Glibc that aren't yet in any released tarball. Download the required source, and create a tarball: export CVSROOT=:pserver:anoncvs@sources.redhat.com:/cvs/glibc cvs -z3 co libc unset CVSROOT mv libc glibc-2.3-$(date +%Y%m%d) tar -cf glibc-2.3-$(date +%Y%m%d).tar glibc-2.3-$(date +%Y%m%d) bzip2 glibc-2.3-$(date +%Y%m%d).tar rm -rf glibc-2.3-$(date +%Y%m%d) 3. GCC 3.3. It has been released, and it works fine, but it has yet to get merged into the book. The LFS book with GCC 3.3 can be found here: http://linuxfromscratch.org/~winkie/book/ 4. NPTL - duh. Grab the latest tarball from here. ftp://people.redhat.com/drepper/nptl/ 5. H J Lu's Binutils - This isn't absolutely necessary, but it is highly recommended for the latest TLS support and bugfixes. Inline Installation =================== It is imparative that you use the tarballs that we downloaded earlier (Glibc CVS, and H J Lu's Binutils). I know it's stupid to say this, but it is VERY IMPORTANT. Ch.5 -- Installing Kernel Headers --------------------------------- When installing the kernel headers, it is highly recommended that you install the headers for the kernel that you will be running on the LFS system (2.5.xx), and not something from some other kernel (e.g. 2.4.20). Though it has not been tested, it may be possible to compile against headers other than those for the kernel you'll be running. When installing the headers, you must use the "make include/asm" command in place of "make symlinks". The latter no longer works in dev kernels. Ch.5 -- Installing Glibc ------------------------ While inside the Glibc directory, extract the NPTL tarball as you would normally do for linuxthreads. You may notice that linuxthreads is already present within our CVS image. Ignore this. Configure Glibc with the following command: ../glibc-*/configure --prefix=/stage1 --enable-add-ons=nptl \ --disable-profile --enable-kernel=2.4.0 \ --with-binutils=/stage1/bin --with-headers=/stage1/include \ --without-gd --with-tls --with-__thread NOTE: Do not modify the --enable-kernel parameter. It is true that we most definately won't be using a 2.4 kernel, passing anything higher has been known to cause instabilities. Just leave this alone. Ch.5 -- Installing GCC - Pass 2 ------------------------------- Some tests will fail, this is to be expected. You may wish to examine why the tests fail, as an overwhelming majority of them are just due to the updated warning messages in GCC 3.3, where the tests have not been updated to accept the new syntax. Ch.6 -- Installing Kernel Headers --------------------------------- See the Chapter 5 note for kernel headers. Ch.6 -- Installing Glibc ------------------------ Use the following command to configure Glibc: ../glibc-*/configure --prefix=/usr --libexecdir=/usr/bin \ --enable-add-ons=nptl --disable-profile --enable-kernel=2.4.0 \ --with-headers=/usr/include --with-tls --with-__thread Ch.6 -- Installing GCC ---------------------- See the Chapter 5 note for GCC. Ch.6 -- Installing Modutils --------------------------- Feel free to skip this package and install module-init-tools in it's place. Modutils is useful to 2.5 kernels. Ch.6 -- Installing Sysklogd --------------------------- The following patch is required to compile Sysklogd against 2.5 kernels: http://www.linuxfromscratch.org/~winkie/downloads/sysklogd-1.4.1.patch.bz2 Feedback ======== If you have had success getting NPTL working on your system, have an idea for something I should add, or want to report a bug, please e-mail me to let me know. Hell, e-mail to tell me my hint sucks if that floats your boat, just give me some feedback! Thanks. E-mail: winkie@linuxfromscratch.org