Bug #75975 Armv7h - compilation error (mysql-cluster 7.3.8)
Submitted: 20 Feb 2015 9:13 Modified: 8 Oct 2015 7:46
Reporter: sebekk23 _ Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S4 (Feature request)
Version:7.3.8 OS:Linux (Allwinner A20 (Armv7ve hardfloat))
Assigned to: CPU Architecture:Any
Tags: arm, Compilation

[20 Feb 2015 9:13] sebekk23 _
Description:
Hi

I'm trying to build mysql on armv7 but only i can get is error :) like follows: 

[ 64%] Built target ndbsched
Scanning dependencies of target ndbd
[ 64%] Building CXX object storage/ndb/src/kernel/CMakeFiles/ndbd.dir/main.cpp.o
[ 64%] Building CXX object storage/ndb/src/kernel/CMakeFiles/ndbd.dir/ndbd.cpp.o                                                                                                                                                                   
[ 64%] Building CXX object storage/ndb/src/kernel/CMakeFiles/ndbd.dir/angel.cpp.o                                                                                                                                                                  
In file included from /home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/include/debugger/EventLogger.hpp:24:0,
                 from /home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/src/kernel/angel.cpp:31:
/home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/include/kernel/signaldata/EventReport.hpp: In function 'void reportShutdown(const ndb_mgm_configuration*, NodeId, int, bool, bool, bool, Uint32, Uint32, Uint32)':
/home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/include/kernel/signaldata/EventReport.hpp:85:43: warning: 'theData.EventReport::eventType' is used uninitialized in this function [-Wuninitialized]
   eventType = (nodeId << 16) | (eventType & 0xFFFF);
                                           ^
/home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/src/kernel/angel.cpp:52:18: note: 'theData' was declared here
   Uint32 length, theData[25];
                  ^
[ 64%] Building CXX object storage/ndb/src/kernel/CMakeFiles/ndbd.dir/SimBlockList.cpp.o
Linking CXX executable ndbd
[ 64%] Built target ndbd
[ 64%] Building CXX object storage/ndb/src/kernel/vm/CMakeFiles/ndbsched_mt.dir/mt.cpp.o
/home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/src/kernel/vm/mt.cpp: In member function 'bool thr_send_threads::data_available()':
/home/h3x0r/mysql-cluster/src/mysql-cluster-gpl-7.3.8/storage/ndb/src/kernel/vm/mt.cpp:1249:9: error: 'rmb' was not declared in this scope
     rmb();
         ^
continued in attachment

It has something to do with memory barrier but i can not figure out what i should include and where to make it work with ARM Kernel Sources.

Could you provide some info that will help me to build MySQL on ARM ?

My env is like follows:
- mysql source version: 7.3.8

- CMAKE
cmake "../$pkgbase-cluster-gpl-$pkgver" \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DWITH_NDBCLUSTER_STORAGE_ENGINE=ON \
-DWITH_NDBCLUSTER=ON \
-DWITH_NDBMTD=ON \
-DWITH_NDB_JAVA=OFF \
-DCMAKE_AR=/usr/bin/gcc-ar \
-DCMAKE_RANLIB=/usr/bin/gcc-ranlib \
-DBUILD_CONFIG=mysql_release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DSYSCONFDIR=/etc/mysql \
-DMYSQL_DATADIR=/srv/mysql \
-DMYSQL_UNIX_ADDR=/run/mysqld/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DINSTALL_INFODIR=share/mysql/docs \
-DINSTALL_MANDIR=share/man \
-DINSTALL_PLUGINDIR=lib/mysql/plugin \
-DINSTALL_SCRIPTDIR=bin \
-DINSTALL_INCLUDEDIR=include/mysql \
-DINSTALL_DOCREADMEDIR=share/mysql \
-DINSTALL_SUPPORTFILESDIR=share/mysql \
-DINSTALL_MYSQLSHAREDIR=share/mysql \
-DINSTALL_DOCDIR=share/mysql/docs \
-DINSTALL_SHAREDIR=share/mysql \
-DWITH_ZLIB=system \
-DWITH_SSL=system \
-DWITH_LIBWRAP=OFF \
-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc' \
-DWITH_EXTRA_CHARSETS=complex \
-DWITH_EMBEDDED_SERVER=ON \
-DWITH_ARCHIVE_STORAGE_ENGINE=ON \
-DWITH_BLACKHOLE_STORAGE_ENGINE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=ON \
-DWITH_PARTITION_STORAGE_ENGINE=ON \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=ON \
-DWITHOUT_FEDERATED_STORAGE_ENGINE=ON \
-DENABLE_DOWNLOADS=1 \
-DCMAKE_C_FLAGS="-fPIC ${CFLAGS} -fno-strict-aliasing -DBIG_JOINS=1 -fomit-frame-pointer -fno-delete-null-pointer-checks" \
-DCMAKE_CXX_FLAGS="-fPIC ${CXXFLAGS} -fno-strict-aliasing -DBIG_JOINS=1 -felide-constructors -fno-rtti -fno-delete-null-pointer-checks" \
-DWITH_MYSQLD_LDFLAGS="-pie ${LDFLAGS},-z,now"

- C,CPP, MAKE, DISTCC flags:
CFLAGS="-march=armv7ve -mfloat-abi=hard -mfpu=neon-vfpv4 -mcpu=cortex-a7 -mtune=cortex-a7 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
CXXFLAGS="-march=armv7ve -mfloat-abi=hard -mfpu=neon-vfpv4 -mcpu=cortex-a7 -mtune=cortex-a7 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
CPPFLAGS="-D_FORTIFY_SOURCE=2 -march=armv7ve -mfloat-abi=hard -mfpu=neon-vfpv4 -mcpu=cortex-a7 -mtune=cortex-a7 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
- MAKEFLAGS="-j11"
DISTCC_HOSTS="r1.dom markone.dom marktwo.dom vulcanone.dom vulcantwo.dom"
- OS Linux (ArmArchLinux)
- Kernel: Linux r1 3.4.104+ #1 SMP PREEMPT Thu Jan 8 15:40:40 CET 2015 armv7l GNU/Linux
- gcc
gcc (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Without distcc and with -j1 options same error occurs.

How to repeat:
Just try to do in sources directory: make -j1 (or make -j11 with appropriate number of machines and with distcc configured)

Suggested fix:
None
[20 Feb 2015 9:16] sebekk23 _
Full error log

Attachment: full_log.txt (text/plain), 7.93 KiB.

[20 Feb 2015 9:17] sebekk23 _
And one more little thing:
even with only cmake . -BUILD_CONFIG=mysql_release and make -j1 error occurs
[20 Feb 2015 17:52] sebekk23 _
I think that severit S4 is little bit too low ;) - update to S2
[23 Feb 2015 17:59] sebekk23 _
mysql-cluster-gpl-7.3.0 builds without problems.
[5 Mar 2015 10:53] Mikael Ronström
In order to compile MySQL Cluster one have to add support for memory barriers.
The current level support is found in the file mt-asm.h in the directory storage/ndb/src/kernel/vm

I don't know how to implement memory barriers in ARM v7 but this is what is required to get it
to compile on ARM v7.
[5 Mar 2015 11:07] Mikael Ronström
A bit of googling on the topic found the following:

For armv6 need use:

static inline void memory_barrier() { asm volatile ("mcr p15, 0, %0, c7, c10, 5" : : "r" (0) : "memory"); }
For armv7 need use:

static inline void memory_barrier() { asm volatile ("dmb" : : : "memory"); }
Universal embedded gcc full memory barrier:

static inline void memory_barrier() { __sync_synchronize(); }

This was found at:

https://github.com/genodelabs/genode/issues/692

Check mt-asm.h for examples of how other architectures are supported, obviously also
requires understanding the proper #ifdef flags in the compiler for ASM v7.
[25 Apr 2015 18:37] Gustaf Thorslund
Hi Sebo,

Did you make any progress using Mikael's comments?

Also note that ARM is not a supported platform for MySQL Cluster, so I'm changing the severity back to S4 (Feature request). For a list of supported platforms, please have a look at:

  https://www.mysql.com/support/supportedplatforms/cluster.html

Regards,
Gustaf
[26 May 2015 1: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 Oct 2015 7:46] Gustaf Thorslund
Verified as described using:
* MySQL Cluster 7.4.7 (from github)
* Community maintained Ubuntu 14.04 for RPi2 from https://wiki.ubuntu.com/ARM/RaspberryPi
* A RaspberryPi 2