mysql-client-5.6.14 build failed

Sun Renjie sunrenjie6 at gmail.com
Sun Oct 13 16:23:24 UTC 2013


Hi Alexander:

> Date: Wed, 02 Oct 2013 02:04:02 +0300
> From: Alexander Panyushkin <vsityz at gmail.com>
> To: freebsd-current at freebsd.org
> Subject: mysql-client-5.6.14 build failed
> Message-ID: <524B54E2.1040608 at gmail.com>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Hi all.
>
> mysql-client-5.6.14 not build with clang

>
> /usr/ports/databases/mysql56-client/work/mysql-5.6.14/sql/net_serv.cc:48:
> In file included from /usr/include/c++/v1/algorithm:627:
> /usr/include/c++/v1/memory:968:39: error: expected unqualified-id
>      template <class _Up> static __two test(...);

The build fails because the 'test' macro is defined in include/my_global.h:
#define test(a)         ((a) ? 1 : 0)
yet libc++ standard header <memory> defines 'test' as the name of a
function:
template <class _Up> static char test(typename _Up::pointer* = 0);

MySQL C++ source code files like sql/net_serv.cc #include <my_global.h>
before
including <memory>. This ordering will result in the 'test' function in
<memory>
macro-expanded into nonsense.

After a casual scan, more C++ source code files might be affacted:

client/mysql.cc:45:#include <algorithm>
client/mysqlbinlog.cc:58:#include <algorithm>
client/mysqltest.cc:51:#include <algorithm>
client/sql_string.cc:28:#include <algorithm>
...

I've prepared an ad hoc patch that modifies include/my_global.h to include
<memory> before defining the 'test' macro, so that further including of
<memory>
will be uneffective and hence unharmful. I believe this likely to be useful
before there is a fix from upstream mysql or libc++. Now this package
(mysql56-client) and the server counterpart (mysql56-server) build fine.
I'm new
to FreeBSD so I hope someone else could produce a better solution. Any
comments
will be highly appreciated! Thanks.

Here comes the patch (see also the attachment):

root at r:/svn/ports/databases/mysql56-client # cat
files/patch-include_my_global.h
--- include/my_global.h.orig    2013-10-13 22:22:33.000000000 +0800
+++ include/my_global.h 2013-10-13 22:26:57.000000000 +0800
@@ -460,6 +460,13 @@
 typedef unsigned short ushort;
 #endif

+/* the macro test() below will break libc++ standard header <memory> which
+   defines function named 'test'; fix it in an ad hoc manner by including
the
+   header before definition of the macro. */
+#ifdef  __cplusplus
+#include <memory>
+#endif
+
 #define swap_variables(t, a, b) { t dummy; dummy= a; a= b; b= dummy; }
 #define test(a)                ((a) ? 1 : 0)
 #define set_if_bigger(a,b)  do { if ((a) < (b)) (a)=(b); } while(0)


----------
Regards,
Renjie Sun


More information about the freebsd-current mailing list