Bug #13621 Does not compile on m68k: /usr/include/asm/atomic.h: 'local_irq_save' was not d
Submitted: 29 Sep 2005 20:08 Modified: 27 Apr 2006 2:46
Reporter: Christian Hammers (Silver Quality Contributor) (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:4.0 OS:Linux (Debian GNU/Linux Sid)
Assigned to: Oleksandr Byelkin CPU Architecture:Any

[29 Sep 2005 20:08] Christian Hammers
Description:
Hello

Please don't include kernel headers, their maintainers do not care about applications...
We had a similar problem in Juli but this one is very slightly different:

http://buildd.debian.org/fetch.php?&pkg=mysql-dfsg-4.1&ver=4.1.14-5&arch=m68k&stamp=112784...

if g++ -DDEFAULT_BASEDIR=\"/usr\" -DDATADIR="\"/var/lib/mysql\"" -DDEFAULT_CHARSET_HOME="\"/usr\"" -DSHAREDIR="\"/usr/share/mysql\"" -DHAVE_CONFIG_H -I. -I. -I.. -I../include -I../include -I.    -O3 -DDBUG_OFF -DBIG_JOINS=1 -felide-constructors -fno-rtti -O2   -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
/usr/include/asm/atomic.h: In function 'int atomic_add_return(int, atomic_t*)':
/usr/include/asm/atomic.h:91: error: 'local_irq_save' was not declared in this scope
/usr/include/asm/atomic.h:95: error: 'local_irq_restore' was not declared in this scope
/usr/include/asm/atomic.h: In function 'int atomic_sub_return(int, atomic_t*)':
/usr/include/asm/atomic.h:105: error: 'local_irq_save' was not declared in this scope
/usr/include/asm/atomic.h:109: error: 'local_irq_restore' was not declared in this scope
make[3]: *** [my_new.o] Error 1
make[3]: Leaving directory `/build/buildd/mysql-dfsg-4.1-4.1.14/mysys'

How to repeat:
Compile on the m68k architecture with a recent gcc-4.0 suite.
See above URL for the complete build log with configure statement.

Suggested fix:
Don't include any kernel header.

Maybe you find ideas how to fix it in the following bug reports:
http://bugs.mysql.com/bug.php?id=7851
http://bugs.mysql.com/bug.php?id=11845
[29 Sep 2005 22:57] Christian Hammers
A possible will be uploaded to this bug report now.
[29 Sep 2005 22:57] Christian Hammers
fix

Attachment: 14_configure__gcc-atomic.h.diff (text/plain), 755 bytes.

[5 Oct 2005 8:58] Sergei Golubchik
Christian, could you upload the config.log (and, preferrably, the output of sh -x ./configure <your usual configure options>) ?

configure tries to detect whether atomic.h is usable and should not define HAVE_ATOMIC_ADD otherwise.
[3 Nov 2005 17:55] Christian Hammers
Hello

The bug also comes up with MySQL 5.0.15. It seems to be dependend on the GCC version.

The test program from configure.in, I compiled with "gcc -Wall -o t t.c", is:
   #include <asm/atomic.h>
   int main()
   {
          atomic_t v;

          atomic_set(&v, 23);
          atomic_add(5, &v);
          return atomic_read(&v) == 28 ? 0 : -1;
  }

Results:

gcc-2.95: OK
gcc-3.3: 
   /usr/include/asm/atomic.h: In Funktion »atomic_add«:
  /usr/include/asm/atomic.h:21: error: inconsistent operand constraints in an `asm'

The relevant lines of atomic.h are:
  static __inline__ void atomic_add(int i, atomic_t *v)
  {
        __asm__ __volatile__("addl %1,%0" : "=m" (*v) : "id" (i), "0" (*v));
  }

Be aware that the kernel headers are obviously not the same on every architecture and kernel version so yours might look slightly different. This one is from 2.6.13-rc3.

I'm not sure if the primary problem is in MySQL or gcc vs. the kernel.

bye,

-christian-
[3 Nov 2005 22:12] Christian Hammers
Forget my last mail, I did the compile tests in the wrong chroot :)
Attached you find config.log and the build log.

bye,

-christian-
[3 Nov 2005 22:12] Christian Hammers
config.log

Attachment: config.log.bz2 (application/octet-stream, text), 27.75 KiB.

[3 Nov 2005 22:12] Christian Hammers
build output

Attachment: log.bz2 (application/octet-stream, text), 15.70 KiB.

[10 Nov 2005 0:01] Jim Winstead
I think the thing to do here is to make sure our tests for the atomic_*() functions are done using C++ by adding the appropriate AC_LANG_{SAVE,CPLUSPLUS,RESTORE} magic.
[10 Nov 2005 19:17] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/32152
[28 Nov 2005 12:39] Sergei Golubchik
From the error message it does not look like c/c++ is an issue.
Jim are you sure your fix will solve the problem ?
Christian did the fix helped you ?
[12 Dec 2005 13:40] Lenz Grimmer
Is BUG#15244 a duplicate of this one? Also see http://lists.mysql.com/packagers/264 for a related discussion.
[29 Dec 2005 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[30 Jan 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[30 Jan 2006 7:18] Valeriy Kravchuk
Christian,

Please, check the patch proposed and inform about the results.
[7 Feb 2006 0:32] Christian Hammers
Hello

Sorry, I can't verify it currently as I don't have access to a reasonable fast m68k machine
but I will report if the patch does not work after the next 5.0.x release, ok?

bye,

-christian-
[7 Feb 2006 8:29] Valeriy Kravchuk
OK. I'll set status "Need Feedback" until that.
[8 Mar 2006 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[8 Apr 2006 20:02] Oleksandr Byelkin
-1) early version is affected, too
 0) it is not related to m68k
 1) the patch helps
[10 Apr 2006 18:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4736
[25 Apr 2006 6:08] Oleksandr Byelkin
pushed to 5.1.10, 5.0.21, 4.1.19 and 4.0.27

It was a problem with configure and including atomic operations header file (atomic.h) on some linux distributions (like altlinux, and some other)
[27 Apr 2006 2:46] Paul DuBois
Noted in 4.0.27, 4.1.19, 5.0.21, 5.1.10 changelogs.

Avoid trying to include <asm/atomic.h> when it doesn't work in C++
code. (Bug #13621)