This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH/libiberty] fix build of gdb/binutils with clang.
- From: Yunlian Jiang <yunlian at google dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 19 May 2015 11:08:47 -0700
- Subject: Re: [PATCH/libiberty] fix build of gdb/binutils with clang.
- Authentication-results: sourceware.org; auth=none
- References: <CAMsPy2vps4WX9ax-JfPCGdWbRw=deyu+OuqpgojSJFSe6e+HHg at mail dot gmail dot com> <CAKOQZ8wXKGAxKgcetJxPPWXgxaeNrbLf-E_o6Tz2zbjYF6VfQg at mail dot gmail dot com> <CAMsPy2v+MduooHaBA8hhiTcrq_1NeQm1X-LnOrMEoouUQii4kg at mail dot gmail dot com> <CAKOQZ8z7ME_yEbW3YgMWCLyRVz+w3wjYz7LNayBBBmC1atFYHA at mail dot gmail dot com> <CAMsPy2s2A8U-vTE8u9y+P+xmESKMSuHD=6RV798KNEQKbZdXUg at mail dot gmail dot com> <CAKOQZ8ybeY+6bC0XXVy4Ge3QPEcg6XcvhwBuXQjHhLRTMabm8g at mail dot gmail dot com> <CAMsPy2s9vwa+Y3fR4Xc8k5jnJG__jwWAbF2y0bbSfmz0bEYfYQ at mail dot gmail dot com> <CAKOQZ8zw5TUQ5uP60CuSrAokqohR1_Aq=F5-cGPYqSnL--jPzQ at mail dot gmail dot com>
I could do that and it make the compilation of libiberty passes.
However, I have some other problem when using clang to build gdb
because of libiberty.
Some c file from other component may include 'libiberty.h' which contains
the following
#if !HAVE_DECL_ASPRINTF
/* Like sprintf but provides a pointer to malloc'd storage, which must
be freed by the caller. */
extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
#endif
The HAVE_DECL_ASPRINTF is defined in config.h under libiberty directory.
If the other c file only includes libiberty.h and does not include the
libiberty/config.h and
at the same time, _GNU_SOURCE is defind, the same error happens.
On Mon, May 18, 2015 at 4:52 PM, Ian Lance Taylor <iant@google.com> wrote:
> On Mon, May 18, 2015 at 4:26 PM, Yunlian Jiang <yunlian@google.com> wrote:
>>
>> Yes, the problem is libiberty is compiling some files
>> with _GNU_SOURCE defined and some not. So the configure
>> file does not include "#define _GNU_SOURCE".
>
> As far as I can see it should be fine to define _GNU_SOURCE when
> compiling all libiberty files.
>
> Ian