[MDEV-14541] 10.2.11 hits gcc bug and does not compile on ubuntu16 arm64 Created: 2017-11-30  Updated: 2018-05-08  Resolved: 2018-02-16

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Mroonga
Affects Version/s: 10.2.11
Fix Version/s: 10.1.32, 10.2.14, 10.3.5

Type: Bug Priority: Major
Reporter: David Thompson (Inactive) Assignee: Sergey Vojtovich
Resolution: Fixed Votes: 0
Labels: None

Attachments: File cc8Erc9A.out.gz    
Issue Links:
Problem/Incident
causes MDEV-15138 ubuntu arm64 fails to build packages ... Closed
Epic Link: arm64 optimization

 Description   

Tried to build 10.2.11 from source tag mariadb-10.2.11 and this hits a gcc compiler bug on ubuntu16. This does not occur on centos 7. I also re-verified that mariadb-10.2.10 still builds fine so this appears to be a gcc 5 bug in conjunction with a code change in 10.2.11.

This is one of the build failures (will attach the gcc dump file too):

[ 53%] Building C object storage/myisam/CMakeFiles/myisam.dir/sp_key.c.o
cd /home/ubuntu/server/builddir/storage/myisam && /usr/bin/aarch64-linux-gnu-gcc  -DHAVE_CONFIG_H -DHAVE_SYSTEMD -D_FILE_OFFSET_BITS=64 -I/home/ubuntu/server/builddir/include -I/home/ubuntu/server/include -I/home/ubuntu/server/sql -I/home/ubuntu/server/builddir/pcre -I/home/ubuntu/server/pcre  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security  -pie -fPIC -Wl,-z,relro,-z,now -fstack-protector --param=ssp-buffer-size=4 -DWITH_INNODB_DISALLOW_WRITES -O3 -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing  -Wno-uninitialized -D_FORTIFY_SOURCE=2 -DDBUG_OFF   -Wdate-time -D_FORTIFY_SOURCE=2  -fvisibility=hidden -o CMakeFiles/myisam.dir/sp_key.c.o   -c /home/ubuntu/server/storage/myisam/sp_key.c
Preprocessed source stored into /tmp/cc8Erc9A.out file, please attach this to your bugreport.
 
=== BEGIN GCC DUMP ===
// Target: aarch64-linux-gnu
// Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.5' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-arm64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-arm64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-arm64 --with-arch-directory=aarch64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
// Thread model: posix
// gcc version 5.4.0 20160609 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.5)
//
// /home/ubuntu/server/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c: In function 'grn_ts_op_not_equal_evaluate':
// /home/ubuntu/server/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c:3824:18: internal compiler error: in gen_aarch64_vcond_internalv2div2df, at config/aarch64/aarch64-simd.md:2353
//        out_ptr[i] = grn_ts_op_ ## type ## _ ## kind(buf_ptrs[0][i],\
//                   ^
// /home/ubuntu/server/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c:3863:5: note: in expansion of macro 'GRN_TS_OP_CHK_EVALUATE_CASE'
//      GRN_TS_OP_CHK_EVALUATE_CASE(type, FLOAT, float)\
//      ^
// /home/ubuntu/server/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c:3893:3: note: in expansion of macro 'GRN_TS_OP_CHK_EVALUATE'
//    GRN_TS_OP_CHK_EVALUATE(not_equal)
//    ^
// Please submit a full bug report,
// with preprocessed source if appropriate.
// See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.



 Comments   
Comment by Sergei Golubchik [ 2017-11-30 ]

Does it happen in 10.1 too? Groonga sources are mostly the same there.

Comment by David Thompson (Inactive) [ 2017-11-30 ]

I didn't check that specifically but it builds fine with 10.2.10 so we can conclude the same i think. Workaround for now is to build without mroonga:

cmake -DPLUGIN_MROONGA=NO .

This compiles at least.

Comment by Daniel Bartholomew [ 2017-11-30 ]

Adding this so we don't forget:

To compile with autobake-deb.sh, first do the following:

export CMAKEFLAGS="-DPLUGIN_MROONGA=NO"

Comment by Sandeep sethia [ 2017-12-04 ]

I don’t see any crash on Ubuntu for tag u suggested

Details

1)root@ubuntu:/ssd/sandeep/server/BUILD# git branch

  • (HEAD detached at mariadb-10.2.11)
    10.3

2) Compiler used:

gcc (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609 Copyright (C) 2015 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.

3) cmake -DCMAKE_INSTALL_PREFIX=/run1/sandeep/mariadb_v7 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/ssd/sandeep ../

4) root@ubuntu:/run1/sandeep/mariadb_v7/bin# ./mysqld --help ./mysqld Ver 10.2.11-MariaDB for Linux on aarch64 (Source distribution) Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Starts the MariaDB database server.

Usage: ./mysqld [OPTIONS]

For more help options (several pages), use mysqld --verbose --help.
Not sure if different compiler options is issue here as we doing with O2.

Comment by Sandeep sethia [ 2017-12-14 ]

David/Sergey ,

Do you still see the issue with the above commands i shared? Can you share your cmake command?

Comment by Sergey Vojtovich [ 2017-12-15 ]

I confirm I can still reproduce this on 10.2 revision 0e69d0b094365c36d01180d10fcc6534143a25b5.

cmake -DBUILD_CONFIG=mysql_release && make -j 40

/home/svoj/devel/mariadb/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c: In function 'grn_ts_op_not_equal_evaluate':
/home/svoj/devel/mariadb/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c:3824:18: internal compiler error: in gen_aarch64_vcond_internalv2div2df, at config/aarch64/aarch64-simd.md:2353
       out_ptr[i] = grn_ts_op_ ## type ## _ ## kind(buf_ptrs[0][i],\
                  ^
/home/svoj/devel/mariadb/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c:3863:5: note: in expansion of macro 'GRN_TS_OP_CHK_EVALUATE_CASE'
     GRN_TS_OP_CHK_EVALUATE_CASE(type, FLOAT, float)\
     ^
/home/svoj/devel/mariadb/storage/mroonga/vendor/groonga/lib/ts/ts_expr_node.c:3893:3: note: in expansion of macro 'GRN_TS_OP_CHK_EVALUATE'
   GRN_TS_OP_CHK_EVALUATE(not_equal)
   ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/build.make:3350: recipe for target 'storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/ts/ts_expr_node.c.o' failed
make[2]: *** [storage/mroonga/vendor/groonga/lib/CMakeFiles/libgroonga.dir/ts/ts_expr_node.c.o] Error 1

gcc-5.real (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609

Comment by David Thompson (Inactive) [ 2018-02-02 ]

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882417

fixed in gcc7 ? Also seems to indicate lowering -O3 to -O2 might workaround

Comment by Sergey Vojtovich [ 2018-02-16 ]

Pushed workaround to 10.1:

commit a351f40cba21244b8b6c2d8b86631407abd62dd9
Author: Sergey Vojtovich <svoj@mariadb.org>
Date:   Fri Feb 16 14:14:43 2018 +0400
 
    MDEV-14541 - Workaround GCC ICE on ARM64
 
diff --git a/storage/mroonga/vendor/groonga/lib/CMakeLists.txt b/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
index 6765261..2274e95 100644
--- a/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
+++ b/storage/mroonga/vendor/groonga/lib/CMakeLists.txt
@@ -177,3 +177,8 @@ if(GRN_WITH_MRUBY)
     FILES ${EXPRESSION_TREE_RUBY_SCRIPTS}
     DESTINATION "${GRN_RELATIVE_RUBY_SCRIPTS_DIR}/expression_tree")
 endif()
+
+# Workaround GCC ICE on ARM64
+IF(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
+  ADD_COMPILE_FLAGS(ts/ts_expr_node.c COMPILE_FLAGS "-fno-tree-loop-vectorize")
+ENDIF()

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