[MDEV-13009] 10.1.24 does not compile on architectures without 64-bit atomics Created: 2017-06-06  Updated: 2017-09-22  Resolved: 2017-06-14

Status: Closed
Project: MariaDB Server
Component/s: Compiling, Storage Engine - InnoDB
Affects Version/s: 10.1.24, 10.0.31
Fix Version/s: 10.1.25, 10.0.33, 10.2.7, 10.3.1

Type: Bug Priority: Major
Reporter: James Cowgill Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: None
Environment:

Debian Stretch 32-bit MIPS


Issue Links:
Problem/Incident
is caused by MDEV-12674 Innodb_row_lock_current_waits has ove... Closed
Relates
relates to MDEV-13705 10.0.32 does not compile on architect... Closed

 Description   

Attempting to compile mariadb 10.1.24 on 32-bit MIPS fails with this error:

In file included from /«PKGBUILDDIR»/storage/innobase/lock/lock0wait.cc:29:0:
/«PKGBUILDDIR»/storage/innobase/include/srv0mon.h:649:8: error: 'ib_mutex_t' does not name a type
 extern ib_mutex_t monitor_mutex;
        ^~~~~~~~~~
storage/innobase/CMakeFiles/innobase.dir/build.make:1334: recipe for target 'storage/innobase/CMakeFiles/innobase.dir/lock/lock0wait.cc.o' failed

This appears to be caused by this change from MDEV-12674:
https://github.com/MariaDB/server/commit/ff166093741df0bd91ba24e02714ef882073c51b#diff-088335ea9de1d271e432c61d4c8c12e6L39

Adding the missing #include "sync0types.h" again fixes the issue.



 Comments   
Comment by Marko Mäkelä [ 2017-06-13 ]

jcowgill, thank you for pointing this out.
I was under the impression that all platforms would support 64-bit atomics, but you proved me wrong.

For the record, InnoDB in MariaDB 10.2 will only support platforms with 64-bit atomics. Also MySQL 5.7 is only supporting 64-bit atomics.

I will consider using a mutex-based fallback for 64-bit atomics for the affected 10.1 platforms. Another option would be to ditch the atomics and reintroduce MDEV-12674 on the affected platforms.

Comment by James Cowgill [ 2017-06-13 ]

OK. If (since you're talking about mutex fallback) you don't need lock-free atomics, you alternatively link against GCC's libatomic which provides implementations of missing atomics using locks for architectures which don't implement them natively.

Comment by Marko Mäkelä [ 2017-06-13 ]

I was able to repeat the problem by applying the following patch to disable 64-bit atomics on my AMD64 development platform:

diff --git a/storage/innobase/include/os0sync.h b/storage/innobase/include/os0sync.h
index bb225c53dfe..a5f95c6b43b 100644
--- a/storage/innobase/include/os0sync.h
+++ b/storage/innobase/include/os0sync.h
@@ -399,7 +399,7 @@ Atomic compare-and-swap and increment for InnoDB. */
 # endif
 
 # ifdef HAVE_IB_GCC_ATOMIC_BUILTINS_64
-#  define HAVE_ATOMIC_BUILTINS_64
+#  undef HAVE_ATOMIC_BUILTINS_64
 # endif
 
 /**********************************************************//**
diff --git a/storage/xtradb/include/os0sync.h b/storage/xtradb/include/os0sync.h
index 7bc591b2911..a2ca7431caf 100644
--- a/storage/xtradb/include/os0sync.h
+++ b/storage/xtradb/include/os0sync.h
@@ -451,7 +451,7 @@ Atomic compare-and-swap and increment for InnoDB. */
 # endif
 
 # ifdef HAVE_IB_GCC_ATOMIC_BUILTINS_64
-#  define HAVE_ATOMIC_BUILTINS_64
+#  undef HAVE_ATOMIC_BUILTINS_64
 # endif
 
 /**********************************************************//**

Strangely, the XtraDB code compiles just fine with the above patch. InnoDB needs the following:

diff --git a/storage/innobase/include/srv0mon.h b/storage/innobase/include/srv0mon.h
index 2d5ff22cc21..316a467b6ff 100644
--- a/storage/innobase/include/srv0mon.h
+++ b/storage/innobase/include/srv0mon.h
@@ -644,6 +644,7 @@ Use MONITOR_DEC if appropriate mutex protection exists.
 # define srv_mon_create() ((void) 0)
 # define srv_mon_free() ((void) 0)
 #else /* HAVE_ATOMIC_BUILTINS_64 */
+# include "sync0types.h"
 /** Mutex protecting atomic operations on platforms that lack
 built-in operations for atomic memory access */
 extern ib_mutex_t	monitor_mutex;

For 10.2, it might be the case that my_atomic_add64() and friends are already working out of the box. jcowgill, can you confirm this?

Comment by James Cowgill [ 2017-06-14 ]

I've been building MariaDB in the context of Debian which already has some patches applied to it. With 10.2, I needed this patch (with some tweaks) to get MariaDB to build on MIPS: https://sources.debian.net/src/mariadb-10.1/10.1.24-3/debian/patches/c11_atomics.patch/ Without it I get "error: #error atomic ops for this platform are not implemented"

After applying that patch everything seems to work OK. In any case that is a different bug to this one.

Comment by Otto Kekäläinen [ 2017-06-26 ]

This needs to be backported to 10.0.31 as well to get security updates into Debian and Ubuntu, where .31 stopped building on certain platforms. Here the regression is visible on PowerPC (the old one, not 64-bit): https://bugs.launchpad.net/ubuntu/+source/mariadb-10.0/+bug/1698689

cvicentiu will look into the issue later this week

Comment by Vicențiu Ciorbaru [ 2017-06-28 ]

The reason why xtradb works even without the # include "sync0types.h" is due to how "univ.i" (included by srv0mon.h) includes other files and how those files subsequently include "sync0types.h". This difference in behaviour comes from the HOTBACKUP extention that Percona has added to xtradb.

Comment by Marko Mäkelä [ 2017-09-04 ]

otto, sorry, I missed your request to backport this to 10.0. I just did that under MDEV-13705.

Comment by Marko Mäkelä [ 2017-09-04 ]

jcowgill, are you able to compile 10.2.7 without any patches related to this? This fix was merged to 10.2 (potentially incorrectly; that is why I ask) a day after your comment, and first released in 10.2.7.

Comment by James Cowgill [ 2017-09-22 ]

@marko, I can confirm that this particular bug is fixed in 10.2.7 (the original error goes away). However, I can't build 10.2.7 on mips without any patches because there are some other atomics issues. I needed a patch similar to this one applied in Debian to build it:
https://sources.debian.net/src/mariadb-10.1/10.1.25-1/debian/patches/c11_atomics.patch/

Generated at Thu Feb 08 08:02:12 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.