Bug #110226 Build fails when CMAKE_CXX_FLAGS_RELEASE is set because -DNDEBUG isn't set
Description:
I appreciate the docs here:
https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html#cmake-compiler-f...
... with respect to advice on changing the optimizer level. In my case I want a Release build that uses -O2 and -O3 will be used by default. But when I set -DCMAKE_C_FLAGS_RELEASE and -DCMAKE_CXX_FLAGS_RELEASE the build for 8.0.31 and 8.0.32 fails.
How to repeat:
This is on Ubuntu 22.04 that uses gcc 11.3.0
I start with this cmake command line based on the advice at:
https://dev.mysql.com/doc/refman/8.0/en/source-configuration-options.html#cmake-compiler-f...
The advice was:
"If you set flags that affect optimization (-Onumber), you must set the CMAKE_C_FLAGS_build_type and/or CMAKE_CXX_FLAGS_build_type options, where build_type corresponds to the CMAKE_BUILD_TYPE value."
And then has an example, and the example doesn't use -DNDEBUG.
BF=" -g1 "
CF=" $BF "
CXXF=" $BF "
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DWITH_SSL=system -DWITH_ZLIB=bundled \
-DMYSQL_MAINTAINER_MODE=0 -DENABLED_LOCAL_INFILE=1 \
-DCMAKE_INSTALL_PREFIX=$1 -DWITH_BOOST=$PWD/../boost \
-DCMAKE_CXX_FLAGS="$CXXF" -DCMAKE_C_FLAGS="$CF" \
-DCMAKE_C_FLAGS_RELEASE="-O2" \
-DCMAKE_CXX_FLAGS_RELEASE="-O2" \
-DWITH_NUMA=ON -DWITH_ROUTER=OFF -DWITH_MYSQLX=OFF -DWITH_UNIT_TESTS=OFF
The build with the above cmake command line fails. Some errors are:
/home/mdcallag/b/mysql-8.0.31/storage/perfschema/pfs_variable.cc: In member function ‘bool PFS_system_variable_cache::init_show_var_array(enum_var_type, bool)’:
/home/mdcallag/b/mysql-8.0.31/storage/perfschema/pfs_variable.cc:95:24: warning: unused variable ‘LOCK_plugin’ [-Wunused-variable]
95 | extern mysql_mutex_t LOCK_plugin;
| ^~~~~~~~~~~
In file included from /home/mdcallag/b/mysql-8.0.31/include/my_alloc.h:42,
from /home/mdcallag/b/mysql-8.0.31/include/sql_string.h:44,
from /home/mdcallag/b/mysql-8.0.31/sql/basic_ostream.h:28,
from /home/mdcallag/b/mysql-8.0.31/sql/binlog_ostream.h:27,
from /home/mdcallag/b/mysql-8.0.31/include/mysql/group_replication_priv.h:32,
from /home/mdcallag/b/mysql-8.0.31/plugin/replication_observers_example/replication_observers_example.cc:33:
/home/mdcallag/b/mysql-8.0.31/plugin/replication_observers_example/replication_observers_example.cc: In function ‘int trans_after_commit(Trans_param*)’:
/home/mdcallag/b/mysql-8.0.31/plugin/replication_observers_example/replication_observers_example.cc:327:13: error: ‘debug_sync_set_action’ was not declared in this scope
327 | assert(!debug_sync_set_action(current_thd, STRING_WITH_LEN(act)));
| ^~~~~~~~~~~~~~~~~~~~~
/home/mdcallag/b/mysql-8.0.31/include/my_dbug.h:173:7: note: in definition of macro ‘DBUG_EXECUTE_IF’
173 | a1 \
I can avoid build failures by adding -DNDEBUG as in ...
BF=" -g1 "
CF=" $BF "
CXXF=" $BF "
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DWITH_SSL=system -DWITH_ZLIB=bundled \
-DMYSQL_MAINTAINER_MODE=0 -DENABLED_LOCAL_INFILE=1 \
-DCMAKE_INSTALL_PREFIX=$1 -DWITH_BOOST=$PWD/../boost \
-DCMAKE_CXX_FLAGS="$CXXF" -DCMAKE_C_FLAGS="$CF" \
-DCMAKE_C_FLAGS_RELEASE="-O2 -DNDEBUG" \
-DCMAKE_CXX_FLAGS_RELEASE="-O2 -DNDEBUG" \
-DWITH_NUMA=ON -DWITH_ROUTER=OFF -DWITH_MYSQLX=OFF -DWITH_UNIT_TESTS=OFF
Suggested fix:
Either the cmake files or the docs should be updated. The doc update should be easy, just add -DNDEBUG. I have limited cmake skills so I don't have an opinion on whether this is a bug in the cmake support.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.