Bug #93744 Can't compile mysql-5.7 source in the git repository
Submitted: 26 Dec 2018 18:57 Modified: 28 Dec 2018 13:06
Reporter: Justin Swanhart Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S1 (Critical)
Version:5.7.24 OS:Debian (9.6)
Assigned to: CPU Architecture:Other (amd64)

[26 Dec 2018 18:57] Justin Swanhart
Description:
I am trying to build MySQL from source, but the CMake script generates a test resulting in a type conversion error.

error:
-- Configuring incomplete, errors occurred!
See also "/root/mysql-server/build/CMakeFiles/CMakeOutput.log".
See also "/root/mysql-server/build/CMakeFiles/CMakeError.log".

root@debian-c-32-64gib-nyc1-01:~/mysql-server/build# tail /root/mysql-server/build/CMakeFiles/CMakeError.log -n20
CMakeFiles/cmTC_81983.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_81983.dir/src.c.o' failed
make[1]: *** [CMakeFiles/cmTC_81983.dir/src.c.o] Error 1
make[1]: Leaving directory '/root/mysql-server/build/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_81983/fast' failed
make: *** [cmTC_81983/fast] Error 2

Source file was:

    #include <rpc/xdr.h>
    bool_t putlong(XDR* xdr, long *longp)
                   { return (bool_t)(*longp + xdr->x_handy); }
    int main() {
      XDR xdr;
      struct xdr_ops ops;
      long l;

      ops.x_putlong = putlong;
      return (int)ops.x_putlong(&xdr, &l);
    }

How to repeat:
Follow the directions and place wolfSSL in the extra/ directory.
mkdir build/
cd build/
cmake .. -D
cmake .. -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../boost -DWITH_SSL=wolfssl

Suggested fix:
Cast the pointer in the test?
[27 Dec 2018 0:04] Justin Swanhart
Here is a patch to fix two issues with building, but others remain.

diff --git a/rapid/plugin/group_replication/configure.cmake b/rapid/plugin/group_replication/configure.cmake
index 16544429543..851b2ef9e7f 100644
--- a/rapid/plugin/group_replication/configure.cmake
+++ b/rapid/plugin/group_replication/configure.cmake
@@ -76,8 +76,9 @@ CHECK_STRUCT_HAS_MEMBER("struct ifreq" ifr_name net/if.h

 CHECK_STRUCT_HAS_MEMBER("struct xdr_ops" x_putint32 rpc/xdr.h
                         HAVE_XDR_OPS_X_PUTINT32)
+
 CHECK_STRUCT_HAS_MEMBER("struct xdr_ops" x_getint32 rpc/xdr.h
-                        HAVE_XDR_OPS_X_GETINT32)
+                       HAVE_XDR_OPS_X_GETINT32)

 CHECK_C_SOURCE_COMPILES(
   "
@@ -110,7 +111,7 @@ IF(NOT APPLE
   CHECK_C_SOURCE_COMPILES(
     "
     #include <rpc/xdr.h>
-    int main() { XDR xdr; xdr.x_handy = -1; return (int)xdr.x_handy; }
+    int main() { XDR xdr; xdr.x_handy = -1ul; return (int)xdr.x_handy; }
     "
     OLD_XDR)

@@ -140,8 +141,8 @@ IF(NOT APPLE
   CHECK_C_SOURCE_COMPILES(
     "
     #include <rpc/xdr.h>
-    bool_t putlong(XDR* xdr, long *longp)
-                   { return (bool_t)(*longp + xdr->x_handy); }
+    bool_t putlong(XDR* __xdrs, const long *__lp)
+                   { return (bool_t)(*__lp + __xdrs->x_handy); }
     int main() {
       XDR xdr;
       struct xdr_ops ops;
[27 Dec 2018 9:58] Terje Røsten
hi!

Thanks for your report!

Are you using MySQL 8.0 or MySQL 5.7?

The wolfSSL option is only present in MySQL 8.0 I think?

Any special reason you want wolfSSL and not OpenSSL (the default)?
[27 Dec 2018 12:16] Tor Didriksen
the xdr/rpc warning is a red herring, something else must have gone wrong during the configure step (like wolfssl not being supported in 5.7)

The putlong test is *supposed* to fail on debian, note the result variable is called X_PUTLONG_NOT_USE_CONST, and see the corresponding usage of the C macro in
xcom_transport.c
[27 Dec 2018 14:25] Justin Swanhart
Oops, I guess you don’t build 5.7 with wolfSSL.  That is just a typo.  8.0 can’t find OpenSSL on my box, or it doesn’t work with the version I have.  I didn’t dig into the issue further, and instead used wolfSSL.  5.7 works with th my OpenSSL though.
[27 Dec 2018 14:25] Justin Swanhart
Oops, I guess you don’t build 5.7 with wolfSSL.  That is just a typo.  8.0 can’t find OpenSSL on my box, or it doesn’t work with the version I have.  I didn’t dig into the issue further, and instead used wolfSSL.  5.7 works with th my OpenSSL though.
[27 Dec 2018 18:05] Justin Swanhart
I am not using wolfSSL with 5.7.  This is my steps:
1) clone mysql-server
2) checkout 5.7 branch
3) mkdir build
4) cd build/
5) cmake .. -DDOWNLOAD_BOOST -DWITH_BOOST=../boost
6) make -j32
[27 Dec 2018 18:12] Justin Swanhart
Tor, apparently my Debian stretch requires const even though that apparently wasn’t  the case the case before.
[27 Dec 2018 21:47] Miguel Solorzano
Then there isn't bug here regarding 5.7 and wolfssl, right?.
[27 Dec 2018 22:53] Justin Swanhart
The problem is building from source causing errors in cmake.  There are type conversion errors and problems with pointer conversion.  WolfSSL is not involved.
[27 Dec 2018 22:58] Justin Swanhart
updated debian version and CPU architecture
[28 Dec 2018 9:37] Tor Didriksen
That particular cmake check (and many others) is expected to fail on Debian 9.
You end up with file ./rapid/plugin/group_replication/include/xcom/xcom.h
which contains this:

/*Definitions*/
/* #undef HAVE_STRUCT_SOCKADDR_SA_LEN */
#define HAVE_STRUCT_IFREQ_IFR_NAME 1
/* #undef HAVE_RPC_INLINE_T */
#define HAVE_XDR_OPS_X_PUTINT32 1
#define HAVE_XDR_OPS_X_GETINT32 1
/* #undef OLD_XDR */
#define X_GETPOSTN_NOT_USE_CONST 1
/* #undef X_PUTLONG_NOT_USE_CONST */

And you will use the last alternative int this #if #elif code, i.e. 
'const long *longp'

/* ARGSUSED */
static bool_t
x_putlong (XDR *xdrs,
#if defined(__APPLE__) && defined(__LP64__)
           const int *intp MY_ATTRIBUTE((unused))
#elif defined(X_PUTLONG_NOT_USE_CONST)
           long *longp MY_ATTRIBUTE((unused))
#else
           const long *longp MY_ATTRIBUTE((unused))
#endif

So 'tail CMakeFiles/CMakeError.log is a red herring.
What *other* cmake warnings/errors are you getting?
[28 Dec 2018 9:52] Terje Røsten
>  8.0 can’t find OpenSSL on my box, or it doesn’t work with the version I have.  

Please make sure libssl-dev is installed, do:

$ apt install libssl-dev

You should then get:

$ dpkg -l libssl-dev | tail -1
ii  libssl-dev:amd64 1.1.0f-3+deb9u2 amd64        Secure Sockets Layer toolkit - development files

Remove previous build/ directory and try again:

$ mkdir build && cd build
$ cmake .. -DWITH_SSL=system
$ make -j32

If this fails, run:

$ make -j1

and post error messages here.
[28 Dec 2018 13:06] Justin Swanhart
I pulled a brand new copy of the source repo and now I can't reproduce the problem.  Closing.