Bug #15244 Compiling
Submitted: 25 Nov 2005 12:07 Modified: 15 Dec 2005 15:53
Reporter: Arkady Volodin Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:4.1.15 OS:Linux (Linux 2.6.14.3 Mandrake 10.1)
Assigned to: CPU Architecture:Any

[25 Nov 2005 12:07] Arkady Volodin
Description:
I compiled 4.1.13a successfully without troubles.
But 4.1.15 fails compile with:

In file included from /usr/include/asm/atomic.h:6,
                 from ../include/my_global.h:280,
                 from mysys_priv.h:17,
                 from my_new.cc:22:
/usr/include/asm/processor.h: In function `void set_in_cr4(long unsigned int)':
/usr/include/asm/processor.h:235: error: `read_cr4' undeclared (first use this function)
/usr/include/asm/processor.h:235: error: (Each undeclared identifier is reported only once for each function it appears in.)
/usr/include/asm/processor.h:237: error: `write_cr4' undeclared (first use this function)
/usr/include/asm/processor.h: In function `void clear_in_cr4(long unsigned int)':
/usr/include/asm/processor.h:244: error: `read_cr4' undeclared (first use this function)
/usr/include/asm/processor.h:246: error: `write_cr4' undeclared (first use this function)
make[2]: *** [my_new.o] Error 1
make[2]: Leaving directory `/tmp/mysql-4.1.15/mysys'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/mysql-4.1.15'
make: *** [all] Error 2

How to repeat:
My system use kernel headers for compiling:
/usr/include/asm -> /usr/src/linux/include/asm-i386
/usr/include/asm-generic -> /usr/src/linux/include/asm-generic
/usr/include/linux -> /usr/src/linux/include/linux
So, all files atomic.h, processor.h and system.h are in /usr/include/asm.
[25 Nov 2005 12:30] Valeriy Kravchuk
Thank you for a problem report. Please, send the ./configure command line you used.
[25 Nov 2005 12:53] Arkady Volodin
All OK.
It's a kernel 2.6.14.3 bug (Em... Maybe send bugreport to Linus? :-) )

Trouble is in <asm/system.h> file.
There is if-definition "#ifdef __KERNEL__" at line 10 throught "#endif /* __KERNEL */" at line 147. So, that define covers all _cr4 functions for <asm/processor.h> (wich included by <asm/atomic.h>) and as in MySQL "__KERNEL__" not defined, *_cr4 functions unavailable.

But this is not end of the story.
Struct "task_struct" at lines 12-13 of system.h can't compile. :-)

So, maybe to solve all that problems we need to move "#endif /* __KERNEL */" from line 147 to line 14 of system.h file.
[25 Nov 2005 13:00] Valeriy Kravchuk
Why not to add that -D__KERNEL__ flag to CFLAGS in the configure command line? Don't bother Linus with such a problems - he has some other things to do...

Can I close this report as "Not a bug", by the way?
[25 Nov 2005 13:11] Arkady Volodin
Such error appears nearly for ALL <asm/> headers with -D__KERNEL__!!! (errors about 500 lines - I cant post all of them here). MySQL IS NOT A KERNEL. :-)

In file included from /usr/include/linux/skbuff.h:20,
                 from /usr/include/linux/if_ether.h:107,
                 from /usr/include/net/ethernet.h:27,
                 from my_gethwaddr.c:78:
/usr/include/linux/time.h:12: error: redefinition of `struct timespec'
/usr/include/linux/time.h:18: error: redefinition of `struct timeval'
/usr/include/linux/time.h:23: error: redefinition of `struct timezone'
/usr/include/linux/time.h:60: error: conflicting types for 'mktime'
/usr/include/time.h:191: error: previous declaration of 'mktime' was here
/usr/include/linux/time.h:60: error: conflicting types for 'mktime'
/usr/include/time.h:191: error: previous declaration of 'mktime' was here
/usr/include/linux/time.h:134: error: redefinition of `struct itimerspec'
/usr/include/linux/time.h:139: error: redefinition of `struct itimerval'
[25 Nov 2005 13:20] Valeriy Kravchuk
OK then - it was just an idea :) Two questions remain:

1. Why are you using kernel headers for compiling thing that is not part of the kernel?
2. What shell we do with this bug report? Do you want me to verify something? To change something in MySQL code to allow you to use kernel headers?
[25 Nov 2005 13:39] Arkady Volodin
>1. Why are you using kernel headers for compiling thing that is not part of the
>kernel?
Everybody are using kernel headers. Maybe some tiny changed by distro creators, but normally /usr/include/asm and /usr/src/linux/include/asm-i386 (for i386 platform) must be indentical.
/usr/include/linux must be indentical with /usr/src/linux/include/linux. and so on.

>2. What shell we do with this bug report? Do you want me to verify something? To
>change something in MySQL code to allow you to use kernel headers?
Really, I dont know. :-)
[25 Nov 2005 14:25] Valeriy Kravchuk
Closed as not a bug in MySQL code itself.
[25 Nov 2005 19:18] Sergei Golubchik
Well, it's still MySQL bug.
Kernel headers shouldn't be used in application programs :)
We do, and we have a protection against these compilation failures.
Namely, configure checks whether asm/atomic.h can be used and if not, MySQL don't use it.
Apparently, the check is not robust enough, configure was able to compile with asm/atomic.h, but the server was not.

Could you run configure with sh -x ./configure <your normal configure options>
and attach the output to the bugreport ?
(there's [Files] tab for this)
[12 Dec 2005 13:38] Lenz Grimmer
Probably a duplicate of BUG#13621? A similar discussion came up on the packagers mailing list: http://lists.mysql.com/packagers/264
[12 Dec 2005 13:58] Arkady Volodin
Yes, it seems similar.
But I use 32-bit platform, so way to use kernel atomic.h is possible for me.

I simply put _crX functions outside of __KERNEL__ define and MySQL compiled well.

sql-bench and mysql-test tests completed well.
[15 Dec 2005 15:53] Valeriy Kravchuk
Duplicate of bug #13621, I think.