Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Oct 2013 18:52:33 +0200
From:      =?ISO-8859-1?Q?Bernhard_Fr=F6hlich?= <decke@FreeBSD.org>
To:        Sun Renjie <sunrenjie6@gmail.com>
Cc:        vsityz@gmail.com, Current FreeBSD <freebsd-current@freebsd.org>
Subject:   Re: mysql-client-5.6.14 build failed
Message-ID:  <CAE-m3X3XbAWgpzWR8OSvVyS7tS6FX8wq_MAh=oDcmG6EcFAM-A@mail.gmail.com>
In-Reply-To: <CAAgK970O=QopBUHXEJOdrpkgMj88zDLWBmi4U7rsmk9Lh3Y1ZQ@mail.gmail.com>
References:  <CAAgK970O=QopBUHXEJOdrpkgMj88zDLWBmi4U7rsmk9Lh3Y1ZQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Oct 13, 2013 at 6:23 PM, Sun Renjie <sunrenjie6@gmail.com> wrote:
> 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)

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/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAE-m3X3XbAWgpzWR8OSvVyS7tS6FX8wq_MAh=oDcmG6EcFAM-A>