Description:
Compiling with -DWITH_DEBUG=1 and using C++17 resulted in a failure.
Given that the file where the error occurred is 'debug_lo_scanner.cc' and considering that similar bugs have been reported in the past, I suspect that there might be an unresolved issue when using the -DWITH-DEBUG=1 option.
The compilation failure is due to the use of the 'register' storage class specifier in the 'debug_lo_scanner.cc' code, which is no longer supported in C++17.
Error log that occurred during the 'make' process:
----------------------------------------------------------------------------
[ 91%] Building CXX object sql/CMakeFiles/sql_main.dir/__/sql-common/client_authentication.cc.o
/root/bld/sql/debug_lo_scanner.cc: In function ‘int LOCK_ORDER_lex(YYSTYPE*, YYLTYPE*, yyscan_t)’:
/root/bld/sql/debug_lo_scanner.cc:805:32: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
805 | register yy_state_type yy_current_state;
| ^~~~~~~~~~~~~~~~
/root/bld/sql/debug_lo_scanner.cc:806:24: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
806 | register char *yy_cp, *yy_bp;
| ^~~~~
/root/bld/sql/debug_lo_scanner.cc:806:32: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
806 | register char *yy_cp, *yy_bp;
| ^~~~~
/root/bld/sql/debug_lo_scanner.cc:807:22: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
807 | register int yy_act;
| ^~~~~~
/root/bld/sql/debug_lo_scanner.cc:861:42: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
861 | register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
| ^~~~
/root/bld/sql/debug_lo_scanner.cc: In function ‘int yy_get_next_buffer(yyscan_t)’:
/root/bld/sql/debug_lo_scanner.cc:1210:24: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1210 | register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
| ^~~~
/root/bld/sql/debug_lo_scanner.cc:1211:24: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1211 | register char *source = yyg->yytext_ptr;
| ^~~~~~
/root/bld/sql/debug_lo_scanner.cc:1212:22: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1212 | register int number_to_move, i;
| ^~~~~~~~~~~~~~
/root/bld/sql/debug_lo_scanner.cc:1212:38: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1212 | register int number_to_move, i;
| ^
/root/bld/sql/debug_lo_scanner.cc: In function ‘yy_state_type yy_get_previous_state(yyscan_t)’:
/root/bld/sql/debug_lo_scanner.cc:1344:32: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1344 | register yy_state_type yy_current_state;
| ^~~~~~~~~~~~~~~~
/root/bld/sql/debug_lo_scanner.cc:1345:24: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1345 | register char *yy_cp;
| ^~~~~
/root/bld/sql/debug_lo_scanner.cc:1352:34: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1352 | register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
| ^~~~
/root/bld/sql/debug_lo_scanner.cc: In function ‘yy_state_type yy_try_NUL_trans(yy_state_type, yyscan_t)’:
/root/bld/sql/debug_lo_scanner.cc:1377:22: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1377 | register int yy_is_jam;
| ^~~~~~~~~
/root/bld/sql/debug_lo_scanner.cc:1379:24: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1379 | register char *yy_cp = yyg->yy_c_buf_p;
| ^~~~~
/root/bld/sql/debug_lo_scanner.cc:1381:26: error: ISO C++17 does not allow ‘register’ storage class specifier [-Werror=register]
1381 | register YY_CHAR yy_c = 1;
| ^~~~
cc1plus: all warnings being treated as errors
make[2]: *** [sql/CMakeFiles/sql_main.dir/build.make:4304: sql/CMakeFiles/sql_main.dir/debug_lo_scanner.cc.o] 오류 1
make[2]: *** 끝나지 않은 작업을 기다리고 있습니다....
make[1]: *** [CMakeFiles/Makefile2:31975: sql/CMakeFiles/sql_main.dir/all] 오류 2
make: *** [Makefile:166: all] 오류 2
----------------------------------------------------------------------------
How to repeat:
git clone https://github.com/mysql/mysql-server.git
cd mysql-server
git branch -r
git checkout 8.0
git pull
cd /root
wget https://github.com/Kitware/CMake/releases/download/v3.27.1/cmake-3.27.1-linux-x86_64.tar.g...
tar xvf cmake-3.27.1-linux-x86_64.tar.gz
yum -y install ncurses-devel
wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.gz
tar xvf boost_1_77_0.tar.gz
yum -y install centos-release-scl
yum -y install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils
scl enable devtoolset-11 bash
cd /root
mkdir bld
cd bld
/root/cmake-3.27.1-linux-x86_64/bin/cmake -DWITH_BOOST=/root/boost_1_77_0 -DWITH_DEBUG=1 -DWITH_LOCK_ORDER=ON /root/mysql-server/
make
Suggested fix:
I added the following flag to cmake to resolve this issue:
----------------------------------------------------------------------------
-DCMAKE_C_FLAGS="-Wno-register"
----------------------------------------------------------------------------
Therefore, the command used in cmake is as follows:
old (bug):
----------------------------------------------------------------------------
/root/cmake-3.27.1-linux-x86_64/bin/cmake -DWITH_BOOST=/root/boost_1_77_0 -DWITH_DEBUG=1 -DWITH_LOCK_ORDER=ON /root/mysql-server/
----------------------------------------------------------------------------
new (fix):
----------------------------------------------------------------------------
/root/cmake-3.27.1-linux-x86_64/bin/cmake -DCMAKE_C_FLAGS="-Wno-register" -DWITH_BOOST=/root/boost_1_77_0 -DWITH_DEBUG=1 -DWITH_LOCK_ORDER=ON /root/mysql-server/
----------------------------------------------------------------------------
I consider this approach as a temporary solution, and I believe that for a fundamental resolution, modifications in the source code are necessary.