Bug #97547 Mysql server cannot be compiled on aarch64 with gcc 4.8.5
Submitted: 8 Nov 2019 7:43 Modified: 12 Dec 2019 9:38
Reporter: Rungong An Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.7 OS:CentOS
Assigned to: CPU Architecture:ARM

[8 Nov 2019 7:43] Rungong An
Description:
Mysql server cannot be compiled on aarch64 with gcc 4.8.5.

Errors occur below:

/home/test/rgan/mysql/storage/innobase/fts/fts0fts.cc: In function ‘dberr_t fts_sync_index(fts_sync_t*, fts_index_cache_t*)’:
/home/test/rgan/mysql/storage/innobase/fts/fts0fts.cc:4485:1: error: could not split insn
 }
 ^
(insn 737 2259 2265 (parallel [
            (set (reg:DI 0 x0 [orig:150 D.108423 ] [150])
                (plus:DI (mem/v:DI (reg/f:DI 19 x19 [orig:98 D.108434 ] [98]) [-1  S8 A64])
                    (const_int 536870912 [0x20000000])))
            (set (mem/v:DI (reg/f:DI 19 x19 [orig:98 D.108434 ] [98]) [-1  S8 A64])
                (unspec_volatile:DI [
                        (mem/v:DI (reg/f:DI 19 x19 [orig:98 D.108434 ] [98]) [-1  S8 A64])
                        (const_int 536870912 [0x20000000])
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 1 x1))
        ]) /home/test/rgan/mysql/storage/innobase/include/sync0rw.ic:309 1856 {atomic_add_fetchdi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 1 x1)
            (nil))))
/home/test/rgan/mysql/storage/innobase/fts/fts0fts.cc:4485:1: internal compiler error: in final_scan_insn, at final.c:2897
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
/home/test/rgan/mysql/storage/innobase/srv/srv0srv.cc: In function ‘void* srv_purge_coordinator_thread(void*)’:
/home/test/rgan/mysql/storage/innobase/srv/srv0srv.cc:2878:1: error: could not split insn
 }
 ^
(insn 3238 9388 9395 (parallel [
            (set (reg:DI 0 x0 [orig:317 D.104912 ] [317])
                (plus:DI (mem/v:DI (reg/f:DI 21 x21 [1446]) [-1  S8 A64])
                    (const_int 536870912 [0x20000000])))
            (set (mem/v:DI (reg/f:DI 21 x21 [1446]) [-1  S8 A64])
                (unspec_volatile:DI [
                        (mem/v:DI (reg/f:DI 21 x21 [1446]) [-1  S8 A64])
                        (const_int 536870912 [0x20000000])
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 1 x1))
        ]) /home/test/rgan/mysql/storage/innobase/include/sync0rw.ic:309 1856 {atomic_add_fetchdi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 1 x1)
            (nil))))
/home/test/rgan/mysql/storage/innobase/srv/srv0srv.cc:2878:1: internal compiler error: in final_scan_insn, at final.c:2897
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
/home/test/rgan/mysql/storage/innobase/row/row0mysql.cc: In function ‘dberr_t row_drop_table_for_mysql(const char*, trx_t*, bool, bool, dict_table_t*)’:
/home/test/rgan/mysql/storage/innobase/row/row0mysql.cc:4831:1: error: could not split insn
 }
 ^
(insn 3160 9441 9443 (parallel [
            (set (reg:DI 0 x0 [orig:228 D.135349 ] [228])
                (plus:DI (mem/v:DI (reg/f:DI 22 x22 [1144]) [-1  S8 A64])
                    (const_int 536870912 [0x20000000])))
            (set (mem/v:DI (reg/f:DI 22 x22 [1144]) [-1  S8 A64])
                (unspec_volatile:DI [
                        (mem/v:DI (reg/f:DI 22 x22 [1144]) [-1  S8 A64])
                        (const_int 536870912 [0x20000000])
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 6 x6))
        ]) /home/test/rgan/mysql/storage/innobase/include/sync0rw.ic:309 1856 {atomic_add_fetchdi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 6 x6)
            (nil))))
/home/test/rgan/mysql/storage/innobase/row/row0mysql.cc:4831:1: internal compiler error: in final_scan_insn, at final.c:2897
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccnkXSts.out file, please attach this to your bugreport.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/fts/fts0fts.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/test/rgan/mysql/storage/innobase/handler/handler0alter.cc: In member function ‘virtual bool ha_innobase::commit_inplace_alter_table(TABLE*, Alter_inplace_info*, bool)’:
/home/test/rgan/mysql/storage/innobase/handler/handler0alter.cc:9420:1: error: could not split insn
 }
 ^
(insn 7282 20045 20047 (parallel [
            (set (reg:DI 0 x0 [orig:820 D.185654 ] [820])
                (plus:DI (mem/v:DI (reg/f:DI 28 x28 [2516]) [-1  S8 A64])
                    (const_int 536870912 [0x20000000])))
            (set (mem/v:DI (reg/f:DI 28 x28 [2516]) [-1  S8 A64])
                (unspec_volatile:DI [
                        (mem/v:DI (reg/f:DI 28 x28 [2516]) [-1  S8 A64])
                        (const_int 536870912 [0x20000000])
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 3 x3))
        ]) /home/test/rgan/mysql/storage/innobase/include/sync0rw.ic:309 1856 {atomic_add_fetchdi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 3 x3)
            (nil))))
/home/test/rgan/mysql/storage/innobase/handler/handler0alter.cc:9420:1: internal compiler error: in final_scan_insn, at final.c:2897
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
Preprocessed source stored into /tmp/ccRruRSK.out file, please attach this to your bugreport.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/srv/srv0srv.cc.o] Error 1
Preprocessed source stored into /tmp/ccn4vzTY.out file, please attach this to your bugreport.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/row/row0mysql.cc.o] Error 1
Preprocessed source stored into /tmp/ccBcaMuV.out file, please attach this to your bugreport.
make[2]: *** [storage/innobase/CMakeFiles/innobase.dir/handler/handler0alter.cc.o] Error 1
make[1]: *** [storage/innobase/CMakeFiles/innobase.dir/all] Error 2
make: *** [all] Error 2

gcc is 4.8.5
libstdc++ is 6.0.19
libatomic is 1.2.0

How to repeat:
cmake -DCMAKE_BUILD_TYPE=release -DWITH_BOOST=./boost
make

Suggested fix:
vi ./storage/innobase/CMakeLists.txt

change

    ADD_COMPILE_FLAGS(
      btr/btr0btr.cc
      btr/btr0cur.cc
      buf/buf0buf.cc
      gis/gis0sea.cc
      COMPILE_FLAGS "-O0"
      )
to

    ADD_COMPILE_FLAGS(
      btr/btr0btr.cc
      btr/btr0cur.cc
      buf/buf0buf.cc
      gis/gis0sea.cc
      fts/fts0fts.cc
      handler/handler0alter.cc
      row/row0mysql.cc
      srv/srv0srv.cc
      COMPILE_FLAGS "-O0"
      )
[9 Nov 2019 13:22] Terje Røsten
hi!

Can you try with GCC 8 from Devtoolset 8 for CentOS 7 aarch64 instead?

For installing required packages do something like:

$ yum install centos-release-scl
$ yum install devtoolset-8

Then do

$ export CC=/opt/rh/devtoolset-8/root/usr/bin/gcc
$ export CXX=/opt/rh/devtoolset-8/root/usr/bin/g++

and rerun cmake from a clean state.
[11 Nov 2019 1:04] Rungong An
Hi,

I have tried gcc 7.3, it's ok. However, the complied bin files (such as mysqld, libmysqlclient.so) relate on .so files provided by higher version gcc. As other machines do not have the higher version gcc, I need to install higher version gcc on other machines or execute export LD_LIBRARY_PATH before every mysql related command. I consider that's not suitable.
[11 Nov 2019 13:24] Terje Røsten
Please retry with devtoolset 8, it will not add any new runtime dependencies.

$ ldd sql/mysqld               
        linux-vdso.so.1 =>  (0x0000fffea5ab0000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000fffea5a50000)
        libaio.so.1 => /lib64/libaio.so.1 (0x0000fffea5a20000)
        libnuma.so.1 => /lib64/libnuma.so.1 (0x0000fffea59f0000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000fffea59a0000)
        libssl.so.10 => /lib64/libssl.so.10 (0x0000fffea5910000)
        libcrypto.so.10 => /lib64/libcrypto.so.10 (0x0000fffea5700000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000fffea56d0000)
        librt.so.1 => /lib64/librt.so.1 (0x0000fffea56a0000)
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000fffea5580000)
        libm.so.6 => /lib64/libm.so.6 (0x0000fffea54c0000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000fffea5480000)
        libc.so.6 => /lib64/libc.so.6 (0x0000fffea52f0000)
        /lib/ld-linux-aarch64.so.1 (0x0000fffea5ac0000)
        libfreebl3.so => /lib64/libfreebl3.so (0x0000fffea52c0000)
        libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x0000fffea5250000)
        libkrb5.so.3 => /lib64/libkrb5.so.3 (0x0000fffea5140000)
        libcom_err.so.2 => /lib64/libcom_err.so.2 (0x0000fffea5110000)
        libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x0000fffea50b0000)
        libz.so.1 => /lib64/libz.so.1 (0x0000fffea5070000)
        libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x0000fffea5040000)
        libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x0000fffea5010000)
        libresolv.so.2 => /lib64/libresolv.so.2 (0x0000fffea4fd0000)
        libselinux.so.1 => /lib64/libselinux.so.1 (0x0000fffea4f80000)
        libpcre.so.1 => /lib64/libpcre.so.1 (0x0000fffea4f20000)

$ sql/mysqld --version
sql/mysqld  Ver 5.7.28 for Linux on aarch64 (Source distribution)

Note: you might need this patch to build:

diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 219e284..25fe64a 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -53,6 +53,8 @@
 #include <sys/mman.h>
 #endif
 
+#include <sys/prctl.h>
+
 #include "sql_parse.h"    // test_if_data_home_dir
 #include "sql_cache.h"    // query_cache, query_cache_*
 #include "sql_locale.h"   // MY_LOCALES, my_locales, my_locale_by_name

or a backport to 5.7 of:

https://github.com/mysql/mysql-server/commit/cde75f89ba5dff888dfd44adf16b00b72a82c8c1#diff...
[12 Nov 2019 2:40] Rungong An
libstdc++ seems to be a higher version.
[12 Nov 2019 3:53] Rungong An
I mean the libstdc++.so.6 is a soft link, the actual .so file may be a higher version.

I'm not sure whether installing a higher version gcc on aother machine impacts other applications on the machine.
[12 Nov 2019 3:53] Rungong An
I mean the libstdc++.so.6 is a soft link, the actual .so file may be a higher version.

I'm not sure whether installing a higher version gcc on aother machine impacts other applications on the machine.
[12 Nov 2019 9:38] Terje Røsten
GNU G++ from Devtoolset 8 will produce binaries that is compatible with a unmodified libstdc++.so.6.0.19 from libstdc++-4.8.5:

$ sql/mysqld --version 
sql/mysqld  Ver 5.7.28 for Linux on aarch64 (Source distribution)

$ ldd sql/mysqld|grep libstd
        libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000fffcf07b0000)

$ ls -l /lib64/libstdc++.so.6
lrwxrwxrwx 1 root root 19 nov.  11 09:37 /lib64/libstdc++.so.6 -> libstdc++.so.6.0.19

$ rpm -qf /lib64/libstdc++.so.6.0.19 
libstdc++-4.8.5-39.0.4.el7.aarch64

$ rpm -vV libstdc++-4.8.5 |grep /usr/lib64/libstdc++
.........    /usr/lib64/libstdc++.so.6
.........    /usr/lib64/libstdc++.so.6.0.19
.........    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.py
.........    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyc
.........    /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.19-gdb.pyo

That's why I ask you to install these tools.
[13 Dec 2019 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".