MySQL5.7.30 Linux编译过程记录

场景

        CentOS Linux release 7.6.1810 (AltArch)

1)yum安装已有的GCC(gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)),通过scl安装GCC(gcc version 7.3.1 20180303 (Red Hat 7.3.1-5) (GCC) )

MySQL5.7.30版本源码依赖高版本的GCC,启用7.3版本GCC :scl enable devtoolset-7 bash

编译指令:

cmake ../ -DCMAKE_INSTALL_PREFIX=/opt/mysql  -DMYSQL_DATADIR=/opt/mysql/var  -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DENABLE_DTRACE=0 -DDEFAULT_CHARSET=utf8mb4  -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/opt/mysql-src/boost_1_59_0

提示错误: error: could not split insn

/opt/mysql-src/mysql-5.7.30/storage/innobase/handler/handler0alter.cc:9015:1: error: could not split insn
 }
 ^
(insn 7329 19670 19672 (parallel [
            (set (reg:DI 0 x0 [orig:834 D.184765 ] [834])
                (plus:DI (mem/v:DI (reg/f:DI 28 x28 [2541]) [-1  S8 A64])
                    (const_int 536870912 [0x20000000])))
            (set (mem/v:DI (reg/f:DI 28 x28 [2541]) [-1  S8 A64])
                (unspec_volatile:DI [
                        (mem/v:DI (reg/f:DI 28 x28 [2541]) [-1  S8 A64])
                        (const_int 536870912 [0x20000000])
                        (const_int 5 [0x5])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:SI 9 x9))
        ]) /opt/mysql-src/mysql-5.7.30/storage/innobase/include/sync0rw.ic:317 1856 {atomic_add_fetchdi}
     (expr_list:REG_UNUSED (reg:CC 66 cc)
        (expr_list:REG_UNUSED (reg:SI 9 x9)
            (nil))))
/opt/mysql-src/mysql-5.7.30/storage/innobase/handler/handler0alter.cc:9015:1: internal compiler error: in final_scan_insn, at final.c:2897
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.
Preprocessed source stored into /tmp/ccCdCpCd.out file, please attach this to your bugreport.
make[2]: *** [storage/innobase/CMakeFiles/innobase_embedded.dir/build.make:726: storage/innobase/CMakeFiles/innobase_embedded.dir/handler/handler0alter.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2378: storage/innobase/CMakeFiles/innobase_embedded.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
[root@taishan-atlas build]# cmake -version
cmake version 3.12.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).

问题原因:环境中有gcc -4.8.5的没有卸载

问题解决:yum -y remove gcc

如果把gcc version 7.3.1一同卸载,重新安装

2)/usr/bin/c++: No such file or directory

/bin/sh: /usr/bin/c++: No such file or directory
make[2]: *** [mysys_ssl/CMakeFiles/mysys_ssl.dir/build.make:63: mysys_ssl/CMakeFiles/mysys_ssl.dir/crypt_genhash_impl.cc.o] Error 127
make[1]: *** [CMakeFiles/Makefile2:1320: mysys_ssl/CMakeFiles/mysys_ssl.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

解决:重新建立链接 ln -s /usr/bin/gcc  /usr/bin/cc /usr/bin/c++

3)make编译出错

../archive_output_directory/libmysys_ssl.a(my_default.cc.o):(.data.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
make[2]: *** [extra/CMakeFiles/comp_err.dir/build.make:94: extra/comp_err] Error 1
make[1]: *** [CMakeFiles/Makefile2:6587: extra/CMakeFiles/comp_err.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

解决:删除cmake下的build的中间目录,编译的时候引用了GCC4.8.3的参与了编译,make clean不一定有效

4)修复源码中的头文件缺少问题

编辑sql/mysqld.cc 添加头文件#include <sys/prctl.h>

/opt/mysql-src/mysql-5.7.30/sql/mysqld.cc: In function 'passwd* check_user(const char*)':
/opt/mysql-src/mysql-5.7.30/sql/mysqld.cc:1565:12: error: 'prctl' was not declared in this scope
     (void) prctl(PR_SET_DUMPABLE, 1);
            ^~~~~
make[2]: *** [sql/CMakeFiles/sql.dir/build.make:2829: sql/CMakeFiles/sql.dir/mysqld.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:8317: sql/CMakeFiles/sql.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

重新make编译

上一篇:PE知识复习之PE的绑定导入表


下一篇:ROS应用 —— Ubuntu16.04下 科大讯飞语音听写的修改&使用(2)