Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 29248 - mysql fails to compile with an nptl-enabled glibc
Summary: mysql fails to compile with an nptl-enabled glibc
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Gentoo Linux MySQL bugs team
URL: http://bugs.mysql.com/bug.php?id=972
Whiteboard:
Keywords:
: 32240 35999 39209 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-09-21 00:36 UTC by Jason Rhinelander
Modified: 2004-02-07 09:13 UTC (History)
11 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
mysql-nptl.patch (mysql-nptl.patch,818 bytes, patch)
2003-12-01 15:29 UTC, Andy Dustman
Details | Diff
NPTL ebuild patch (mysql-nptl-ebuild.patch,835 bytes, patch)
2003-12-01 15:33 UTC, Andy Dustman
Details | Diff
MySQL 4.0.16 ebuild, supports NPTL (mysql-4.0.16.ebuild,7.46 KB, patch)
2003-12-24 20:11 UTC, Zhen Lin
Details | Diff
Mysql 4.0.17 nptl aware ebuild (mysql-4.0.17.ebuild,7.56 KB, patch)
2004-01-01 03:52 UTC, Ronald Hummelink
Details | Diff
Updated nptl ebuild patch (mysql.nptl.ebuild.patch,918 bytes, patch)
2004-01-02 13:16 UTC, Andy Dustman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Rhinelander 2003-09-21 00:36:18 UTC
MySQL's configure script greps /usr/include/pthread.h for "Linuxthreads"
(configure line 12943, at least as of 4.0.15) to determine if Linux Threads are
available.  With an nptl-enabled glibc, Linuxthreads is _not_ in
/usr/include/pthread.h, so this fails, and MySQL's configure script fails:

...
checking "LinuxThreads"... "Not found"
configure: error: This is a linux system and Linuxthreads was not
found. On linux Linuxthreads should be used.  Please install Linuxthreads
(or a new glibc) and try again.  See the Installation chapter in the
Reference Manual for more information.
 
!!! ERROR: dev-db/mysql-4.0.15 failed.
!!! Function econf, Line 324, Exitcode 1
!!! econf failed


So, what's needed to get MySQL to compile on a recent glibc+nptl+kernel system?



My emerge info:

Portage 2.0.49-r4 (default-x86-1.4, gcc-3.3.1, glibc-2.3.2-r5, 2.6.0-test4-mm2)
=================================================================
System uname: 2.6.0-test4-mm2 i686 Intel(R) Pentium(R) M processor 1400MHz
distcc 2.10 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [enabled]
ACCEPT_KEYWORDS="x86 ~x86 amd64"
AUTOCLEAN="yes"
CFLAGS="-march=pentium4 -O3 -mmmx -msse -msse2 -mfpmath=sse -pipe
-fomit-frame-pointer -funroll-loops -frerun-loop-opt"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config
/usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-march=pentium4 -O3 -mmmx -msse -msse2 -mfpmath=sse -pipe
-fomit-frame-pointer -funroll-loops -frerun-loop-opt"
DISTDIR="/usr/portage/distfiles"
FEATURES="sandbox ccache autoaddcvs distcc"
GENTOO_MIRRORS="ftp://gentoo.mirrors.pair.com"
MAKEOPTS="-j3"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://backup/gentoo-portage"
USE="x86 oss avi crypt cups encode foomaticdb gif jpeg libwww mad mikmod mmx
mpeg ncurses pdflib png quicktime spell truetype xml2 xmms xv zlib directfb
gtkhtml alsa gdbm berkdb slang readline aalib bonobo tcltk guile mysql X sdl gpm
tcpd pam ssl perl imlib oggvorbis gnome gtk opengl mozilla cdr aavm acpi
acpi4linux dga dvd fbcon gd gnomedb gtk2 icc mbox moznoirc nptl pcmcia pic
prebuilt samba sse sse2 threads tiff trusted usb vim-with-x wmf xosd -3dnow -apm
-arts -java -kde -libg++ -motif -nls -qt -svga -python -esd"
Comment 1 Jason Rhinelander 2003-09-21 00:42:51 UTC
Incidentally, this also happened with glibc-2.3.2-r3 - I upgraded to -r5 to see if it would change anything.  Someone reported it on the forums with -r1 as well (http://forums.gentoo.org/viewtopic.php?t=86240).
Comment 2 Chris Yu 2003-09-21 07:22:56 UTC
Same problem with me:
glibc 2.3.2-r1 and 2.3.2-r5

Message:

checking for TCP wrappers library -lwrap... yes
checking for atomic operations... atomic_add atomic_sub
checking if we should use pstack... no
checking for int8... no
checking "LinuxThreads"... "Not found"
configure: error: This is a linux system and Linuxthreads was not
found. On linux Linuxthreads should be used.  Please install Linuxthreads
(or a new glibc) and try again.  See the Installation chapter in the
Reference Manual for more information.

!!! ERROR: dev-db/mysql-4.0.15 failed.
!!! Function econf, Line 324, Exitcode 1
!!! econf failed


emerge info

gentoo root # emerge info
Portage 2.0.49-r4 (default-x86-1.4, gcc-3.3.1, glibc-2.3.2-r1, 2.6.0-test5-love3)
=================================================================
System uname: 2.6.0-test5-love3 i686 AMD Athlon(tm) XP 2000+
distcc 2.10 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.2 [enabled]
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-march=athlon-xp -m3dnow -msse -mfpmath=sse -mmmx -O3  -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -frerun-cse-after-loop  -frerun-loop-opt -falign-functions=4 -maccumulate-outgoing-args -ffast-math  -fprefetch-loop-arrays"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /var/qmail/control /usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-march=athlon-xp -m3dnow -msse -mfpmath=sse -mmmx -O3  -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -frerun-cse-after-loop  -frerun-loop-opt -falign-functions=4 -maccumulate-outgoing-args -ffast-math  -fprefetch-loop-arrays"
DISTDIR="/software/distfiles"
FEATURES="autoaddcvs -sandbox ccache"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="x86 oss apm avi crypt encode foomaticdb gif jpeg libg++ mad mikmod mmx mpeg ncurses pdflib png quicktime truetype xml2 xmms xv zlib gtkhtml gdbm berkdb slang readline tetex bonobo svga tcltk java guile mysql X sdl gpm tcpd pam libwww ssl perl python esd imlib oggvorbis gnome motif opengl mozilla dvd radeon sse 3dnow gtk gtk2 dga -qt -kde -arts -spell -alsa breakme pda nls lirc cups nptl postgres"
Comment 3 Jason Rhinelander 2003-09-29 12:38:51 UTC
Any ideas?
Comment 4 fschneider 2003-10-03 02:24:17 UTC
I don't know if this helps and/or fixes the current problem, and for now,
I
only see it as a hack and not as a solution.

I don't even know if mysql will start and work properly, since I am compiling
my new system (2.6-test5-love3 with nptl) from scratch.

But at least with this patch to the mysql ebuild it compiled on my system:


--- schnipp
--- /var/portage/dev-db/mysql/mysql-4.0.15.ebuild       2003-09-24 22:11:48.000000000
+0200
+++ /mnt/gentoo/var/overportage/dev-db/mysql/mysql-4.0.15.ebuild        2003-09-30
22:00:15.000000000 +0200
@@ -21,7 +21,7 @@
 KEYWORDS="ia64 ~x86 ~sparc ~ppc ~arm ~amd64 ~hppa"
 LICENSE="GPL-2"
 SLOT="0"
-IUSE="static readline innodb berkdb tcpd ssl perl debug"
+IUSE="static readline innodb berkdb tcpd ssl perl debug nptl"

 DEPEND="readline? ( >=sys-libs/readline-4.1 )
        tcpd? ( >=sys-apps/tcp-wrappers-7.6-r6 )
@@ -103,6 +103,9 @@
        myconf="${myconf} `use_with tcpd libwrap`"
        myconf="${myconf} `use_with innodb`"

+       use nptl && myconf="${myconf} --with-pthread --with-named-thread-libs=-lpthread"
+       use nptl && myconf="${myconf} --with-pthread=no"
+
        use ssl \
                && myconf="${myconf} --with-vio --with-openssl" \
                || myconf="${myconf} --without-openssl"
@@ -136,6 +139,15 @@
                --with-embedded-server \
                ${myconf} || die "bad ./configure"

+       if use nptl; then
+               echo -n "#undef HAVE_PTHREAD_RWLOCK_RDLOCK" >>config.h
+               echo -n "#define USE_MUTEX_INSTEAD_OF_RW_LOCKS 1" >>config.h
+#              echo -n "#undef THREAD" >>config.h
+               sed -s "s/ADAPTIVE/REMOVEDCRAP/" include/my_pthread.h >asdf
+               cp asdf include/my_pthread.h
+               echo -n "#undef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP" >>include/my_pthread.h
+       fi
+
        emake || die "compile problem"
 }

--- schnapp

The changes are the following:

1. I have explicitly stated that pthread is the thread library (and not LinuxThreads)
2. there are some problems with the read/write locks from nptl - don't know
whose fault it is mysql's or nptl's -> using mutexes works
3. adaptive mutexes breaks the linker (can't find a certain function)
Comment 5 Jason Rhinelander 2003-10-03 11:15:31 UTC
If I'm not mistaken, shouldn't the second line be || instead of &&?

+       use nptl && myconf="${myconf} --with-pthread --with-named-thread-libs=-lpthread"
+       use nptl && myconf="${myconf} --with-pthread=no"
Comment 6 fschneider 2003-10-03 14:40:26 UTC
Oops! No, this line should be removed, my mistake.

Maybe it did work for me because --with-pthread will be ignored
when you use --with-named-thread-libs.
Comment 7 Jason Rhinelander 2003-10-28 10:39:05 UTC
Your patch doesn't do what you think it does.  For some reason, you have
-n's on all your echos, so everything ends up on one line at the end of config.h:

#undef HAVE_PTHREAD_RWLOCK_RDLOCK#define USE_MUTEX_INSTEAD_OF_RW_LOCKS 1

Additionally, the lack of newlines produces warnings:

../../include/my_config.h:871:73: warning: no newline at end of file
../../include/my_pthread.h:686:45: warning: no newline at end of file

But, when I changed them to echo's without -n's, compilation fails with a
series of syntax errors in thr_rwlock.c.  I uncommented the 'echo "#undef
THREADS"' (and removed the -n), and it then gets much further, but still
dies with:


gcc -O3 -DDBUG_OFF -march=pentium4 -O3 -mmmx -msse -msse2 -mfpmath=sse -pipe
-fomit-frame-pointer -funroll-loops -frerun-loop-opt -DHAVE_ERRNO_AS_DEFINE=1
-DUSE_OLD_FUNCTIONS -rdynamic -o test-sslclient test-sslclient.o  -lstdc++
../dbug/libdbug.a libvio.a ../mysys/libmysys.a ../strings/libmystrings.a
-L/usr/lib -lssl -lcrypto -lpthread -lz -lcrypt -lnsl -lm -lpthread
test-sslserver.o(.text+0x281): In function `client_thread':
: undefined reference to `my_thread_init'
collect2: ld returned 1 exit status
make[2]: *** [test-sslserver] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/portage/mysql-4.0.16/work/mysql-4.0.16/vio'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/mysql-4.0.16/work/mysql-4.0.16'
make: *** [all] Error 2
 
!!! ERROR: dev-db/mysql-4.0.16 failed.
!!! Function src_compile, Line 153, Exitcode 2
!!! compile problem


I should note that the original patch (which really wasn't doing anything
significant to config.h, but _was_ changing my_pthread.h) compiled MySQL
successfully, and appeared to run properly, though I only ran a few simple
queries.  So how important are these lines:

#undef HAVE_PTHREAD_RWLOCK_RDLOCK
#define USE_MUTEX_INSTEAD_OF_RW_LOCKS 1

Without them, it compiles, and appears to run; with them, it fails.
Comment 8 SpanKY gentoo-dev 2003-10-28 22:36:48 UTC
*** Bug 32240 has been marked as a duplicate of this bug. ***
Comment 9 Calvin Walton 2003-11-05 15:24:53 UTC
I have managed to get mysql to compile properly by adding '--with-named-thread-libs=-pthread'.
To do this from the ebuild script, add
use nptl && export CFLAGS="${CFLAGS} --with-named-thread-libs=-pthread"
somewhere before the econf line, and nptl to IUSE. I'll see if I can make
a diff, if that isn't clear enough :)
Comment 10 Calvin Walton 2003-11-05 15:30:24 UTC
um. I made a big typo there. It's myconf that needs to be set - 
use nptl && export myconf="${myconf} --with-named-thread-libs=-pthread"
Comment 11 Calvin Walton 2003-11-05 16:08:11 UTC
never mind - this is part of the patch above, and has some problems. someone
bash me over the head for not checking the other patch fully.
Comment 12 Jason Rhinelander 2003-11-12 16:08:12 UTC
I've had success with both 4.0.16 and 4.1.0 by changing configure to automatically assume LinuxThreads are "found", whether or not they actually are.  The two ways to do this seem to be:

a) Add "/* Linuxthreads */" into /usr/include/pthreads.h, or

b) Change configure to just assume that LinuxThreads are there.

Neither solution is very nice, and MySQL's detection of "grep LinuxThreads" is just plain idiotic.  However, it does compile, and does work with either of these solutions (and the fact that MySQL finally includes subselect support in 4.1.0 is pretty neat).  The MySQL team itself won't help on this issue - it works on Redhat with their hacked in 2.4 NPTL support, so they seem to be refusing to fix any bugs - could the "fix" that Redhat has be so simple as just adding /* Linuxthreads */ into pthreads.h?
Comment 13 Howard B. Golden 2003-11-30 10:44:07 UTC
Re: Comment #12: Jason, I like method (a)! I edited /usr/include/pthread.h by hand, but a patch could edit it and then restore the original after the compile, if necessary.
Comment 14 Andy Dustman 2003-12-01 15:29:24 UTC
Created attachment 21563 [details, diff]
mysql-nptl.patch

Modifies configure.in to pretend we really have LinuxThreads, even
when we don't.
Comment 15 Andy Dustman 2003-12-01 15:33:50 UTC
Created attachment 21565 [details, diff]
NPTL ebuild patch

* Add IUSE="nptl".

* Add DEPEND="nptl? ( sys-devel-autoconf )"

* If USE="nptl", apply mysql-nptl.patch and run autoconf.

This compiles successfully and seems to work but has not been thoroughly
tested.
Comment 16 Artjom Simon 2003-12-05 21:18:17 UTC
Patch from above comment works perfectly.
Please include in official ebuild
Comment 17 SpanKY gentoo-dev 2003-12-18 08:36:34 UTC
*** Bug 35999 has been marked as a duplicate of this bug. ***
Comment 18 Zhen Lin 2003-12-24 20:11:03 UTC
Created attachment 22649 [details, diff]
MySQL 4.0.16 ebuild, supports NPTL

There is a VERY CLEAN fix for this...

add use nptl && myconf="${myconf} --with-named-thread-libs=-lpthread "

then, use "-D_GNU_SOURCE" in CPPFLAGS.

I've checked that it works.

It (rightfully) avoids using LinuxThreads, because NPTL is not LinuxThreads.
Comment 19 Toni Suokas 2003-12-30 09:58:59 UTC
Still can't get mysql to compile MySQL 4.0.16 with the customized ebuild.

It starts to compile but after a while the following errors (or very similar to it are repeated several times

gcc -DMAP_TO_USE_RAID -I. -I. -I.. -I./../include -I../include    -O3 -DDBUG_OFF -O2 -mcpu=pentium4 -funroll-loops -fomit-frame-pointer -pipe -DHAVE_ERRNO_AS_DEFINE=1 -DUSE_OLD_FUNCTIONS  -c `test -f mi_rnext.c || echo './'`mi_rnext.c
In file included from mi_extra.c:17:
myisamdef.h:206: error: syntax error before "pthread_rwlock_t"
myisamdef.h:206: warning: no semicolon at end of struct or union
myisamdef.h:208: warning: data definition has no type or storage class
myisamdef.h:221: error: syntax error before "MYISAM_SHARE"
myisamdef.h:221: warning: no semicolon at end of struct or union
myisamdef.h:246: error: `checksum' redeclared as different kind of symbol
../include/my_sys.h:753: error: previous declaration of `checksum'
myisamdef.h:274: error: syntax error before '}' token
myisamdef.h:492: error: syntax error before '*' token
In file included from mi_info.c:19:
myisamdef.h:206: error: syntax error before "pthread_rwlock_t"
myisamdef.h:206: warning: no semicolon at end of struct or union
myisamdef.h:208: warning: data definition has no type or storage class
myisamdef.h:221: error: syntax error before "MYISAM_SHARE"
myisamdef.h:221: warning: no semicolon at end of struct or union
myisamdef.h:246: error: `checksum' redeclared as different kind of symbol
../include/my_sys.h:753: error: previous declaration of `checksum'
myisamdef.h:274: error: syntax error before '}' token
myisamdef.h:660: error: syntax error before "MYISAM_SHARE"
myisamdef.h:661: error: syntax error before '*' token
myisamdef.h:662: error: syntax error before '*' token
myisamdef.h:492: error: syntax error before '*' token

System info:
Portage 2.0.49-r15 (default-x86-1.4, gcc-3.3.2, glibc-2.3.2-r9, 2.6.0)
=================================================================
System uname: 2.6.0 i686 Intel(R) Xeon(TM) CPU 2.66GHz
Gentoo Base System version 1.4.3.10
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -mcpu=pentium4 -funroll-loops -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config /usr/kde/3/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-O2 -mcpu=pentium4 -funroll-loops -fomit-frame-pointer -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="sandbox ccache autoaddcvs"
GENTOO_MIRRORS="http://trumpetti.atm.tut.fi/gentoo/"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="x86 crypt cups encode foomaticdb gif gpm imlib jpeg libg++ mad mikmod mpeg ncurses nls pdflib png svga truetype xml2 xv zlib gdbm berkdb slang readline mysql tcpd pam libwww ssl perl python acpi acpi4linux apache2 gd imap innodb ipv6 java kerberos krb4 mmx noaudio nptl pic regexp sse tiff -oss -apm -arts -avi -gtk -gtk2 -kde -gnome -motif -oggvorbis -opengl -qt -quicktime -sdl -spell -X -xmms"

I also tried 4.0.17, but it didn't work either.


Comment 20 Ronald Hummelink 2004-01-01 03:52:32 UTC
Created attachment 22942 [details, diff]
Mysql 4.0.17 nptl aware ebuild

Based on the build from Zhen Lin: tell mysql eplicitely about the thread
library and then configure with -D_GNU_SOURCE in CPPFLAGS.
I had to prefix the CPPFLAGS to the configure command, else they weren't used
by configure. This caused a build error much like Tony Soukas shows.
Comment 21 Andy Dustman 2004-01-02 13:16:02 UTC
Created attachment 23034 [details, diff]
Updated nptl ebuild patch

This patch is based on the work in comment #20 and comment #18. There are some
minor spacing cleanups and nptl is added to IUSE. It seems to pass basic smoke
tests.
Comment 22 Bret Towe 2004-01-02 16:32:58 UTC
i just used the ebuild marked as 'Mysql 4.0.17 nptl aware ebuild' on 4.0.16
and after making the patch lines right for .16 it worked great
Comment 23 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-03 20:27:05 UTC
'basic smoke test' as your testing or the mysql offical tests? if it passes those, i'll be happy to commit it to the tree (and stop people bugging me about this).

also, while you are at it for the tests, look very carefully at the memory usage, upstream mysql does NOT support NPTL at all, and many of these hacks like yours lead to massive memory usage. see http://bugs.mysql.com/bug.php?id=972
Comment 24 Zhen Lin 2004-01-03 20:47:06 UTC
Adding self to CC.

About the CPPFLAGS issue -- you have to export it in order for configure to pick it up, or specify it as an environment modifier.

I've been running my modified MySQL since Christmas, no problems so far, RSS is 5.6MB. But, I don't have a 500-strong client load on it, so I can't really say.
Comment 25 Toni Suokas 2004-01-04 10:21:06 UTC
The ebuild on comment #21 works. I haven't been able to test mysql in production use yet (probably some time next week), but I've run all the tests that come with mysql (except the innodb tests) and i've also run the the benchmarks that come bundled (although they seem to stress more perl than mysql ;). I've alse hammered the database with actual web server usage with ab2 and opensta, no problems so far.
Comment 26 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2004-01-23 19:14:37 UTC
*** Bug 39209 has been marked as a duplicate of this bug. ***
Comment 27 Brad House 2004-02-07 09:13:09 UTC
ok, this has been a bug for way too long, I use NPTL on my system,
and have not been able to compile mysql, and it keeps blocking my
emerge. I've committed a patch, it does not depend on USE flags,
and it's meant only for gentoo systems, so do not send upstream.
It should hit the rsync mirrors sometime today.