Bug #115279 Warning about YYSTYPE in mysql-8.0.37
Submitted: 11 Jun 2024 7:10 Modified: 11 Jun 2024 11:51
Reporter: Huaxiong Song (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:8.0.37 OS:Any
Assigned to: CPU Architecture:Any

[11 Jun 2024 7:10] Huaxiong Song
Description:
When compiling MySQL 8.0.37, warnings appeared.

```

[100%] Linking CXX executable ../runtime_output_directory/mysqld
/home/mysql-server/sql/parser_yystype.h:340:7: warning: type ‘union YYSTYPE’ violates the C++ One Definition Rule [-Wodr]
  340 | union YYSTYPE {
      |       ^
/home/mysql-server/storage/innobase/include/fts0pars.h:50: note: a different type is defined in another translation unit
   50 | typedef union YYSTYPE
      | 
/home/mysql-server/sql/parser_yystype.h:341:17: note: the first difference of corresponding definitions is field ‘lexer’
  341 |   Lexer_yystype lexer;  // terminal values from the lexical scanner
      |                 ^
../storage/innobase/fts0pars.y:62: note: a field with different name is defined in another translation unit
/home/mysql-server/sql/sql_yacc.cc:587: warning: type ‘yytokentype’ violates the C++ One Definition Rule [-Wodr]
  587 |   enum yytokentype
      | 
/home/mysql-server/storage/innobase/include/pars0grm.h:46: note: an enum with different value name is defined in another translation unit
   46 | enum yytokentype {
      | 
/home/mysql-server/sql/sql_yacc.cc:589: note: name ‘ABORT_SYM’ differs from name ‘PARS_INT_LIT’ defined in another translation unit
  589 |     ABORT_SYM = 258,
      | 
/home/mysql-server/storage/innobase/include/pars0grm.h:47: note: mismatching definition
   47 |   PARS_INT_LIT = 258,
      | 
[100%] Built target mysqld
Scanning dependencies of target INFO_BIN
[100%] Generating Docs/INFO_BIN
[100%] Built target INFO_BIN
```

How to repeat:
Just compile MySQL-Server 8.0.37.
My gcc and g++ version is:

```
$/opt/rh/devtoolset-11/root/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-11/root/bin/gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-11/root/usr --mandir=/opt/rh/devtoolset-11/root/usr/share/man --infodir=/opt/rh/devtoolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC) 

$/opt/rh/devtoolset-11/root/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-11/root/bin/g++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-11/root/usr --mandir=/opt/rh/devtoolset-11/root/usr/share/man --infodir=/opt/rh/devtoolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC) 
```

Suggested fix:
It seems that the problem is related to commit#8d48f4

Bug#35191333 Fix deprecation and empty-rule warnings in our Bison parsers.
[11 Jun 2024 10:38] MySQL Verification Team
Hello Huaxiong Song,

Thank you for the report and feedback.
Could you please share exact cmake options used for the build along with OS details? Thank you.

So far I have tried this but not seeing any warnings etc:

 /opt/rh/devtoolset-11/root/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-11/root/bin/gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-11/root/usr --mandir=/opt/rh/devtoolset-11/root/usr/share/man --infodir=/opt/rh/devtoolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)

 /opt/rh/devtoolset-11/root/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-11/root/bin/g++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-11/root/usr/libexec/gcc/x86_64-redhat-linux/11/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-11/root/usr --mandir=/opt/rh/devtoolset-11/root/usr/share/man --infodir=/opt/rh/devtoolset-11/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-11.2.1-20220127/obj-x86_64-redhat-linux/isl-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)

-
scl enable devtoolset-11 bash
MYSQL_VERSION="115279"
TARGET=/path/to/$MYSQL_VERSION
rm -rf /path/to/$MYSQL_VERSION
rm -rf bld/
mkdir bld && cd bld
rm -rf CMakeCache.txt

/path/to/cmake-3.28.1/bin/cmake .. \
-DWITH_BOOST=../boost \
-DBUILD_CONFIG=mysql_release

make -j 128

regards,
Umesh
[11 Jun 2024 11:08] Huaxiong Song
Hi, I use the following script to build:

export CC=/opt/rh/devtoolset-11/root/bin/gcc
export CXX=/opt/rh/devtoolset-11/root/bin/g++
cmake .                                \
    -DFORCE_INSOURCE_BUILD=ON          \
    -DCMAKE_BUILD_TYPE="release"   \
    -DMINIMAL_RELWITHDEBINFO=0         \
    -DSYSCONFDIR="mysql"           \
    -DCMAKE_INSTALL_PREFIX="mysql" \
    -DMYSQL_DATADIR="mysql/data"   \
    -DWITH_UNIT_TESTS=0                \
    -DWITH_DEBUG=0                \
    -DINSTALL_LAYOUT=STANDALONE        \
    -DMYSQL_MAINTAINER_MODE=0          \
    -DWITH_EXTRA_CHARSETS=all          \
    -DWITH_ZLIB=bundled                \
    -DWITH_ZSTD=bundled                \
    -DWITH_MYISAM_STORAGE_ENGINE=1     \
    -DWITH_INNOBASE_STORAGE_ENGINE=1   \
    -DWITH_CSV_STORAGE_ENGINE=1        \
    -DWITH_ARCHIVE_STORAGE_ENGINE=1    \
    -DWITH_BLACKHOLE_STORAGE_ENGINE=1  \
    -DWITH_FEDERATED_STORAGE_ENGINE=1  \
    -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
    -DWITH_EXAMPLE_STORAGE_ENGINE=0    \
    -DWITH_TEMPTABLE_STORAGE_ENGINE=1  \
    -DWITH_QUERY_TRACE=1               \
    -DWITH_EXTRA_CHARSETS=all          \
    -DDEFAULT_CHARSET=utf8mb4          \
    -DDEFAULT_COLLATION=utf8mb4_0900_ai_ci \
    -DENABLED_PROFILING=1              \
    -DENABLED_LOCAL_INFILE=1           \
    -DWITH_BOOST="extra/boost/boost_1_77_0.tar.bz2"
make -j 64
[11 Jun 2024 11:24] Huaxiong Song
Sorry, there's one more option to add, and it looks like this is the problem...

-DWITH_LTO=1
[11 Jun 2024 11:51] MySQL Verification Team
Thank you for the details.
Verified as described.

regards,
Umesh