Bug #16769 compling using kernel only code, read_cr4()
Submitted: 25 Jan 2006 7:13 Modified: 21 Feb 2006 15:39
Reporter: Brian Shea Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.0.18 OS:Linux (Slackware 10 + Kernal 2.6.14.4)
Assigned to: CPU Architecture:Any

[25 Jan 2006 7:13] Brian Shea
Description:
make[2]: Entering directory `/usr/src/mysql-5.0.18/mysys'
if g++ -DDEFAULT_BASEDIR=\"/usr/local/mysql-5.0.18\" -DDATADIR="\"/var/mysql\"" -DDEFAULT_CHARSET_HOME="\"/usr/local/mysql-5.0.18\"" -DSHAREDIR="\"/usr/local/mysql-5.0.18/share/mysql\"" -DDEFAULT_HOME_ENV=MYSQL_HOME -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX -DHAVE_CONFIG_H -I. -I. -I.. -I../zlib -I../include -I../include -I.    -O3 -DDBUG_OFF    -fno-implicit-templates -fno-exceptions -fno-rtti -MT my_new.o -MD -MP -MF ".deps/my_new.Tpo" -c -o my_new.o my_new.cc; \
then mv -f ".deps/my_new.Tpo" ".deps/my_new.Po"; else rm -f ".deps/my_new.Tpo"; exit 1; fi
In file included from /usr/include/asm/atomic.h:6,
                 from ../include/my_global.h:309,
                 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:246: error: `write_cr4' undeclared (first use this 
   function)
make[2]: *** [my_new.o] Error 1
make[2]: Leaving directory `/usr/src/mysql-5.0.18/mysys'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/mysql-5.0.18'
make: *** [all] Error 2

------
read_cr4() is defined in asm/system.h but is in a #ifdef __KERNEL__ block and cannot be included in normal non-kernel builds. Not sure why i got this error.

This may very well be a kernel bug but i thought i would contact MySQL first since this is the first build it showed up in. I've built many other libs and packages in the past week with no other issues.

no options passed to configure script and used make to compile. Headers included are from the 2.6.14.4 kernal. Have not tried newer kernel headers files. If this is a kernal version specific issue and not a mysql issue please forgive me. 

I will attemp new kernal header files at a later date. BTW Mysql-4.0.14 has the same problem, so i suspect that something changed in newer kernels.

How to repeat:
System is a Dell with P4 processor. I can send a config.gz file from the kernal build.

run configure and make

make sure /usr/include/asm points to 2.6.14.4 kernal header files. 
make sure /usr/include/asm-generic is link to kernal include/asm-generic
make sure /usr/include/asm-i386 points to /usr/include/asm

using gcc-3.3.4

Suggested fix:
Sorry, i can't help with this. I don't know the mysql code well enough to even begin a sugestion. 

Other than if asm/atomic.h is not required it can be removed.

undef HAVE_ATOMIC_ADD and HAVE_ATOMIC_SUB in config.h

This seems to work for my system. But i'm not sure how this might effect sql performance.

Hope this helps.
[25 Jan 2006 16:24] Valeriy Kravchuk
Thank you for a problem report. Please, check, is it a duplicate of http://bugs.mysql.com/bug.php?id=13621 really
[25 Jan 2006 16:51] Brian Shea
May very well, be, but at first glance that was a M68k System not i386. So if it was fixed for the M68k it should have been looked at on other architectures as well.  I searched for read_cr4() and found no bug list results.

This problem can be tracked back to Mysql-4.0.15.
[8 Feb 2006 14:26] Valeriy Kravchuk
I think, it is, in fact, a duplicate of bug #13621 (2.6 kernel and 5.0.x involved) and/or even bug #7851 (the fix was documented for 4.1.x only there). So, please, wait for the 5.0.x version with fixes for these bugs included, and then try to repeat with it.
[21 Feb 2006 8:37] gilbert LE DREAU
Hello

asm/in processor.h
Because functions set_in_cr4() and clear_in_cr4()
use write_cr4 an read_cr4 who are Kernel functions
juste add
#ifdef __KERNEL__  // before kernel function call

#endif // after kernel function call

like this 

#ifdef __KERNEL__
static inline void set_in_cr4 (unsigned long mask)
{
        unsigned cr4;
        mmu_cr4_features |= mask;
        cr4 = read_cr4();
        cr4 |= mask;
        write_cr4(cr4);
}

static inline void clear_in_cr4 (unsigned long mask)
{
        unsigned cr4;
        mmu_cr4_features &= ~mask;
        cr4 = read_cr4();
        cr4 &= ~mask;
        write_cr4(cr4);
}
#endif

And It will compile
[21 Feb 2006 15:39] Brian Shea
Okay, i will try a new 5.0.x version, but I used the latest (at the time) 5.0.18. I will look at the other bug reports and continue trying to build MySQL.