Bug #102654 Debug mode causes mysql to fail with error: ‘m_sp’ was not declared
Submitted: 18 Feb 2021 20:59 Modified: 21 Feb 2021 18:18
Reporter: Trevor Thomas Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.23 OS:Any
Assigned to: CPU Architecture:Any

[18 Feb 2021 20:59] Trevor Thomas
Description:
(Tested this on my mac running macOS Catalina 10.15.7)

This commit - https://github.com/mysql/mysql-server/commit/aecc02f8c75beb0f5911b02b8364b4e2ba22a25a?bran... appears to be causing issues building with debug mode. 

How to repeat:
1. Checkout mysql using 

wget ‘https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.23.tar.gz’

2. Extract it:

tar -xf mysql-boost-8.0.23.tar.gz

3. cd mysql-8.0.23 && mkdir bld && cd bld

4. Run Cmake

cmake3  -DWITH_DEBUG=1 ../

5. Run make

make -j `nproc`

6. Observe error

error: 'm_sp' was not declared in this scope
[19 Feb 2021 14:21] MySQL Verification Team
Thank you for the bug report. I have not problems to build a debug 8.0.23 server on MAC OSX Catalina:

miguel:mysql-8.0.23 miguel$ runtime_output_directory/mysqld --version
/Users/miguel/tmp/mysql-8.0.23/runtime_output_directory/mysqld  Ver 8.0.23-debug for osx10.15 on x86_64 (Source distribution)
miguel:mysql-8.0.23 miguel$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15.7
BuildVersion:   19H512
miguel:mysql-8.0.23 miguel$
[19 Feb 2021 17:09] Tor Didriksen
I cannot repeat.
Please provide the full error message from the compiler, so we can se what source file this is, what compiler flags were in use, etc.

Please provide a copy of the last few lines of your cmake run, like this:

-- CMAKE_BUILD_TYPE: Debug
-- COMPILE_DEFINITIONS: RAPIDJSON_NO_SIZETYPEDEFINE;RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0;RAPIDJSON_SCHEMA_USE_STDREGEX=1;HAVE_CONFIG_H;__STDC_LIMIT_MACROS;__STDC_FORMAT_MACROS;_USE_MATH_DEFINES;LZ4_DISABLE_DEPRECATE_WARNINGS;HAVE_TLSv13
-- CMAKE_C_FLAGS: -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Wwrite-strings -Wconditional-uninitialized -Wextra-semi -Wmissing-noreturn -Wunreachable-code-break -Wunreachable-code-return
-- CMAKE_CXX_FLAGS: -std=c++14 -fno-omit-frame-pointer -ftls-model=initial-exec  -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wno-null-conversion -Wno-unused-private-field -Wconditional-uninitialized -Wdeprecated -Wextra-semi -Wheader-hygiene -Wnon-virtual-dtor -Wundefined-reinterpret-cast -Winconsistent-missing-destructor-override -Winconsistent-missing-override -Wshadow-field
-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -DDBUG_OFF -ffunction-sections -fdata-sections -O2 -g -DNDEBUG
-- CMAKE_CXX_FLAGS_RELEASE: -DDBUG_OFF -ffunction-sections -fdata-sections -O3 -DNDEBUG
-- CMAKE_CXX_FLAGS_MINSIZEREL: -DDBUG_OFF -ffunction-sections -fdata-sections -Os -DNDEBUG
-- CMAKE_C_LINK_FLAGS: -Wl,-search_paths_first -Wl,-headerpad_max_install_names
-- CMAKE_CXX_LINK_FLAGS: -Wl,-search_paths_first -Wl,-headerpad_max_install_names
-- CMAKE_EXE_LINKER_FLAGS 
-- CMAKE_MODULE_LINKER_FLAGS 
-- CMAKE_SHARED_LINKER_FLAGS 
-- Configuring done
[21 Feb 2021 18:18] Trevor Thomas
-- CMAKE_C_FLAGS: -fno-omit-frame-pointer -ftls-model=initial-exec  -pthread -fdiagnostics-color=auto -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Wwrite-strings -Wjump-misses-init	
-- CMAKE_CXX_FLAGS: -std=c++14 -fno-omit-frame-pointer -ftls-model=initial-exec  -pthread -fdiagnostics-color=auto -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -pthread -fdiagnostics-color=auto -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=2 -Wlogical-op	
-- CMAKE_CXX_FLAGS_DEBUG: -DSAFE_MUTEX -DENABLED_DEBUG_SYNC -g	
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -DDBUG_OFF -ffunction-sections -fdata-sections -O2 -ffunction-sections -fdata-sections -std=c++14 -fno-omit-frame-pointer	
-- CMAKE_CXX_FLAGS_RELEASE: -DDBUG_OFF -ffunction-sections -fdata-sections -O3 -msse -mfpmath=sse -march=core2 -DNDEBUG	
-- CMAKE_CXX_FLAGS_MINSIZEREL: -DDBUG_OFF -ffunction-sections -fdata-sections -Os -DNDEBUG	
-- CMAKE_C_LINK_FLAGS:  -fuse-ld=gold -Wl,--gc-sections	
-- CMAKE_CXX_LINK_FLAGS:  -fuse-ld=gold -Wl,--gc-sections	
-- CMAKE_EXE_LINKER_FLAGS -pthread -rdynamic -Wl,--as-needed	
-- CMAKE_MODULE_LINKER_FLAGS  -static-libstdc++	
-- CMAKE_SHARED_LINKER_FLAGS -pthread -rdynamic -Wl,--as-needed	
-- Configuring done	
-- Generating done	
-- Build files have been written to

I realized the issue is that I need the -DNDEBUG flag as well, see this commit https://github.com/mysql/mysql-server/commit/14ace68c98b17364618f4f4b96add15cbc110d10
[22 Feb 2021 10:20] Tor Didriksen
Indeed. DBUG_OFF and NDEBUG must be in sync.
We have plans to remove the MySQL-specific DBUG_OFF completely,
and use the standard NDEBUG only.