Re: mysql-client-5.6.14 build failed

From: Bernhard Fröhlich <decke_at_FreeBSD.org>
Date: Sun, 13 Oct 2013 18:52:33 +0200
On Sun, Oct 13, 2013 at 6:23 PM, Sun Renjie <sunrenjie6_at_gmail.com> wrote:
> 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
> _at__at_ -460,6 +460,13 _at__at_
>  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)

Please update to latest HEAD (about mid last week) and to latest portstree
because the issues are already fixed in libc++ and the mysql 5.6 port.

Btw your analysis is correct but I have chosen a less intrusive fix in libc++
memory to rename that internal test function and another patch to mysql 5.6.

-- 
Bernhard Froehlich
http://www.bluelife.at/
Received on Sun Oct 13 2013 - 14:52:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:42 UTC