Bug #82515 MySQL 5.7.1{3,4} does not compile ob gcc 6.1.1
Submitted: 9 Aug 2016 15:01 Modified: 26 Sep 2016 22:15
Reporter: Tomasz Kłoczko Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.7.13, 5.7.14, 5.7.15 OS:Fedora (rawhide)
Assigned to: Jon Olav Hauglid CPU Architecture:Any
Tags: myisam

[9 Aug 2016 15:01] Tomasz Kłoczko
Description:
Just been trying to rebuild mysql 5.7.1{3,4} on current Fedora rawhide where is gcc 6.1.1.
Compilation seems it fails in myisam support:

[  7%] Building C object mysys/CMakeFiles/mysys.dir/my_lib.c.o
cd /home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/debug/mysys && /usr/bin/cc  -DHAVE_CONFIG_H -DHAVE_LIBEVENT1 -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -I/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/debug/include -I/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/extra/rapidjson/include -I/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/debug/libbinlogevents/include -I/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/libbinlogevents/export -I/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/include -I/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys  -g -pipe -Wall -Werror=format-security   -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -fPIC -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement -Werror -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DENABLED_DEBUG_SYNC   -o CMakeFiles/mysys.dir/my_lib.c.o   -c /home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys/my_lib.c
/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys/my_lib.c: In function 'my_dir':
/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys/my_lib.c:127:3: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations]
   while (!(READDIR(dirp,(struct dirent*) dirent_tmp,dp)))
   ^~~~~
In file included from /usr/include/features.h:368:0,
                 from /usr/include/stdio.h:27,
                 from /home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/include/my_global.h:41,
                 from /home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys/mysys_priv.h:19,
                 from /home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys/my_lib.c:19:
/usr/include/dirent.h:189:12: note: declared here
 extern int __REDIRECT (readdir_r,
            ^
cc1: all warnings being treated as errors

How to repeat:
Try to rebuild latest mysql using gcc 6.1.1
[9 Aug 2016 15:09] Tomasz Kłoczko
Just realised that it may be problem with dirent.h from rawhide glibc.
Opened https://bugzilla.redhat.com/show_bug.cgi?id=1365576
[9 Aug 2016 16:59] Tomasz Kłoczko
Looks like it is a bug in mysql 5.7 code.
Comment from https://bugzilla.redhat.com/show_bug.cgi?id=1365576

/home/tkloczko/rpmbuild/BUILD/mysql-5.7.14/mysql-5.7.14/mysys/my_lib.c:127:3: error: 'readdir_r' is deprecated [-Werror=deprecated-declarations]

Please stop using readdir_r, it's completely useless.

Status: NEW → CLOSED
Resolution: --- → NOTABUG
Last Closed: 2016-08-09 11:25:12
[10 Aug 2016 1:14] Miguel Solorzano
I couldn't repeat:

[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.o
[100%] Linking CXX executable mysql_embedded
[100%] Built target mysql_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
[100%] Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[miguel@f24 mysql-5.7.14]$ gcc --version
gcc (GCC) 6.1.1 20160621 (Red Hat 6.1.1-3)
Copyright (C) 2016 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.

[miguel@f24 mysql-5.7.14]$ sql/mysqld --version
sql/mysqld  Ver 5.7.14 for Linux on x86_64 (Source distribution)
[miguel@f24 mysql-5.7.14]$
[10 Aug 2016 7:09] Terje Røsten
Hi Tomasz!

Problem is due to change in glibc 2.24 which contain the following change:

 * The readdir_r and readdir64_r functions have been deprecated.  It is
  recommended to use readdir and readdir64 instead.

See for example for more information:
 https://lwn.net/Articles/696469/

To reproduce a system with glibdc 2.24 is needed, using GCC 6.1.1 is not enough.
Fedora rawhide (to be Fedora 25) is one such system.
[24 Sep 2016 17:28] Tomasz Kłoczko
Here is longer comment what needs to be done:
https://womble.decadent.org.uk/readdir_r-advisory.html

Hist checked 5.7.15 and seems problem still is not solved
[24 Sep 2016 17:30] Tomasz Kłoczko
BTW seems not fixing this issue has some secutity consequences.
[26 Sep 2016 22:15] Paul Dubois
Posted by developer:
 
Noted in 5.7.17 changelog.

MySQL now uses readdir() rather than readdir_r(). The latter has been
deprecated since glibc 2.24 and caused debug builds of MySQL and
builds using GCC 6.1.1 to fail.
[28 Sep 2016 15:23] Paul Dubois
Noted in 8.0.1 changelog.