Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Oct 2013 00:23:21 +0800
From:      Sun Renjie <sunrenjie6@gmail.com>
To:        vsityz@gmail.com, freebsd-current@freebsd.org
Subject:   Re: mysql-client-5.6.14 build failed
Message-ID:  <CAAgK970O=QopBUHXEJOdrpkgMj88zDLWBmi4U7rsmk9Lh3Y1ZQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--089e0122814821336b04e8a1c5b7
Content-Type: text/plain; charset=ISO-8859-1

Hi Alexander:

> Date: Wed, 02 Oct 2013 02:04:02 +0300
> From: Alexander Panyushkin <vsityz@gmail.com>
> To: freebsd-current@freebsd.org
> Subject: mysql-client-5.6.14 build failed
> Message-ID: <524B54E2.1040608@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@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

--089e0122814821336b04e8a1c5b7--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAgK970O=QopBUHXEJOdrpkgMj88zDLWBmi4U7rsmk9Lh3Y1ZQ>