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: Mon, 4 May 2015 15:49:43 -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>
There was a similar disscussion here
https://gcc.gnu.org/ml/gcc/2005-11/msg01190.html
The problem is in the configure stage, the __GNU_SOURCE is not
defined, and it could not find
the declaration of asprintf. so it make a declaration of asprintf in
libiberty.h. And for the file floatformat.c,
the __GNU_SOURCE is defined, so it could find another asprintf in
/usr/include/bits/stdio2.h, it also includes
libiberty.h. So these two asprintf conflicts when __USE_FORTIFY_LEVEL is set.
On Sat, May 2, 2015 at 11:58 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Fri, May 1, 2015 at 4:45 PM, Yunlian Jiang <yunlian@google.com> wrote:
>> The test case does not have #define _GNU_SOURCE, so it says
>> error: âasprintfâ undeclared (first use in this function)
>
> OK, then my next question is: why does the test case (I assume you
> mean the test case for whether to set HAVE_DECL_ASPRINTF) not have
> #define _GNU_SOURCE?
>
> What is the background here?
>
> Ian
>
>> On Fri, May 1, 2015 at 3:45 PM, Ian Lance Taylor <iant@google.com> wrote:
>>> On Tue, Apr 28, 2015 at 2:59 PM, Yunlian Jiang <yunlian@google.com> wrote:
>>>> I believe this is the same problem as
>>>> https://gcc.gnu.org/ml/gcc-patches/2008-07/msg00292.html
>>>>
>>>> The asprinf declaration is messed up when using clang to build gdb.
>>>>
>>>> diff --git a/include/libiberty.h b/include/libiberty.h
>>>> index b33dd65..a294903 100644
>>>> --- a/include/libiberty.h
>>>> +++ b/include/libiberty.h
>>>> @@ -625,8 +625,10 @@ extern int pwait (int, int *, int);
>>>> /* Like sprintf but provides a pointer to malloc'd storage, which must
>>>> be freed by the caller. */
>>>>
>>>> +#ifndef asprintf
>>>> extern int asprintf (char **, const char *, ...) ATTRIBUTE_PRINTF_2;
>>>> #endif
>>>> +#endif
>>>>
>>>> /* Like asprintf but allocates memory without fail. This works like
>>>> xmalloc. */
>>>
>>> Why is HAVE_DECL_ASPRINTF not defined?
>>>
>>> Ian