Bug #2173 MySQL's configure does not recognize NPTL
Submitted: 19 Dec 2003 12:47 Modified: 9 May 2005 0:13
Reporter: Sebastian Bergmann Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:4.1 OS:Linux (Linux 2.6.0, glibc-2.3.3_pre2003)
Assigned to: Joerg Bruehe

[19 Dec 2003 12:47] Sebastian Bergmann
MySQL's configure checks for the availability of thread support in the glibc on Linux by looking for the "Linuxthreads" string in /usr/include/pthread.h. This check fails when the glibc was built with the Native POSIX Thread Library (NPTL) instead of LinuxThreads.

As a workaround one can use

  echo '/* Linuxthreads */' >> /usr/include/pthread.h

to build MySQL on systems with an NPTL-enabled glibc. MySQL then configures, builds and runs fine.

How to repeat:


on a Linux system with an NPTL-enabled glibc that does not have the  "Linuxthreads" string in /usr/include/pthread.h.

Suggested fix:
Change the way MySQL's configure script checks for thread support on Linux.
[18 May 2004 14:45] Simon Detheridge
In order to get MySQL 4.1 (checked out from BK on 18/05/04) to compile, I 
found that the fix described in this bug didn't actually help. 
However, I got it to compile by adding '--with-pthread 
--with-named-thread-lib=-lpthread' to ./configure, and setting 
CPPFLAGS="-D_GNU_SOURCE" ./configure --with-pthread 
--with-named-thread-lib=-lpthread --blah-blah-blah
[16 Jun 2004 11:05] Hartmut Holzgraefe
We only support Linux glibcs with LinuxThreads for now
as we have experienced server lockups with NPTL.
That's why we check for the string "Linuxthrads" being
present in the header file.

A warning from configure about NPTL not being support
might be better though in this case instead of just
insisting on Linuxthreads.
[31 Aug 2004 18:46] Arkadiusz Miskiewicz
Well, if NPTL is not supported (which is preety bad because LinuxThreads are obsolete and not supported by glibc people) then still checking headers only is wrong thing.

Many Linux distributors provide currently glibc and libpthread in both versions - NPTL (and TLS) enabled in /lib/tls/ + LinuxThreads version in /lib _but_ headers in /usr/include/ are from LinuxThreads so your test will detect that there is LinuxThreads but in fact libpthread from /lib/tls (NPTL version) will be used.

Moreover new distros releases drop LinuxThreads support and provide NPTL version _only_.

IMO best thing to do is just drop that silly linuxthreads test and let people test with NPTL, too.
[28 Sep 2004 7:10] Joerg Bruehe
Discussions at the Malta DevCon had this result:
- build must be possible with any thread lib, whether "Linuxthreads" or "NPTL";
- due to previous problems with NPTL, building with it may issue a warning message;
- build with NPTL will be tried and resulting binary will be tested;
- use of cpp symbol "HAVE_LINUXTHREADS" in the sources will be checked.
[31 Mar 2005 5:26] Greg Fortune
Had a question on #mysql this evening about NPTL support and arjen said NPTL works for Linux 2.6.  Is this simply out of date or do the notes regarding server lockups still stand?
[29 Apr 2005 9:17] Joerg Bruehe
This note also applies to bug#5871 and bug#9497:

Sorry for the delay in fixing this - solved now.
Patch is pushed to 4.1 (for 4.1.12) and 5.0 (for 5.0.6) BK trees.

Detailed explanation:
Some Linux distributions still use a header file with the old "Linuxthreads" comment even after switching to NPTL. The current MySQL code, which was designed for Linuxthreads, also works if the system comes with NPTL, so the old hack "add a Linuxthreads comment" is still correct for all versions which do not include this patch.

With this patch, "configure" tries to use 'getconf GNU_LIBPTHREAD_VERSION' to tell whether "Linuxthreads" or "NPTL" is installed. If this fails, it falls back to the old methog of 'grep Linuxthreads /usr/include/pthread.h'.
(This will happen on some old distributions: they include "getconf", but the program does not handle the parameter "GNU_LIBPTHREAD_VERSION". It is unlikely that these should come with NPTL, so the header file check will not only work but also yield the correct response.)

Note to users of 4.0:
This patch is not backported into 4.0, as that release is considered too stable for this change.
Should you really require this, I propose you extract the change from 4.1 "configure.in".
Please note that in 4.0 you _must_ define 'HAVE_LINUXTHREADS' even for a NPTL system, because this symbol is used for some other purposes in addition to the threads package.
For 4.1 and 5.0, these (mis)uses have been corrected as part of the NPTL changes. (This correction across several modules is the main reason why the patch is not applied to 4.0.)
[9 May 2005 0:13] Paul Dubois
Note in 4.1.2, 5.0.6 changelogs.
[1 Aug 2006 2:52] K K
a humble request from a new linux/MySQL user. Please be more explicit about the steps to fix the problem.  As of right now i'm confused about what I need to do to make MySQL 4 work on Fedora Core 4.  I'm looking through all related bugs trying to piece together the necessary changes. 
For example the patch mentions adding the line '#undef HAVE_NPTL' to the my_global.h file.  But do I need to remove the '#' to make it active.
Then there's a suggestion to import changes from configure.in of 4.1 release to the same file in 4.0, but which changes?
The solution also mentions changes in several places for the 4.1 release.  Do I need to make all of those changes as well?
Your clarifications will be much appreciated.
I can be reached at outre2001<ignore>at<ignore>yahoo<ignore>com