public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ian Lance Taylor <iant@google.com>
To: Yunlian Jiang <yunlian@google.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH/libiberty] fix build of gdb/binutils with clang.
Date: Wed, 20 May 2015 20:15:00 -0000	[thread overview]
Message-ID: <CAKOQZ8wmD7Fk7oLUbYccCAQTgdOj1jHDgGJ7k2nhO0msGzJPpQ@mail.gmail.com> (raw)
In-Reply-To: <CAMsPy2tx79MJnBfEzC+9nTk6j0zMEv5hGp9AEVDGedmP0CqK7g@mail.gmail.com>

This is OK if GCC bootstraps.

Thanks.

Ian

On Wed, May 20, 2015 at 11:25 AM, Yunlian Jiang <yunlian@google.com> wrote:
> I have the following change to make libiberty compile with _GNU_SOURCE defined
> and remove the declaration of asprintf in libiberty.h if
> HAVE_DECL_ASPRINTF is not
> defined.
>
> diff --git a/include/libiberty.h b/include/libiberty.h
> index b33dd65..8e096a0 100644
> --- a/include/libiberty.h
> +++ b/include/libiberty.h
> @@ -621,7 +621,7 @@ extern int pexecute (const char *, char * const *,
> const char *,
>
>  extern int pwait (int, int *, int);
>
> -#if !HAVE_DECL_ASPRINTF
> +#if defined(HAVE_DECL_ASPRINTF) && !HAVE_DECL_ASPRINTF
>  /* Like sprintf but provides a pointer to malloc'd storage, which must
>     be freed by the caller.  */
>
> diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in
> index f06cc69..624420d 100644
> --- a/libiberty/Makefile.in
> +++ b/libiberty/Makefile.in
> @@ -113,7 +113,8 @@ installcheck: installcheck-subdir
>
>  INCDIR=$(srcdir)/$(MULTISRCTOP)../include
>
> -COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR)
> $(HDEFINES) @ac_libiberty_warn_cflags@
> +COMPILE.c = $(CC) -c @DEFS@ $(CFLAGS) $(CPPFLAGS) -I. -I$(INCDIR) \
> +               $(HDEFINES) @ac_libiberty_warn_cflags@ -D_GNU_SOURCE
>
>  # Just to make sure we don't use a built-in rule with VPATH
>  .c.$(objext):
> diff --git a/libiberty/configure b/libiberty/configure
> index b06cab2..c6758b0 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -5130,6 +5130,9 @@ $as_echo "#define NEED_DECLARATION_ERRNO 1" >>confdefs.h
>  fi
>
>
> +$as_echo "#define _GNU_SOURCE 1" >>confdefs.h
> +
> +
>  # Determine sizes of some types.
>  # The cast to long int works around a bug in the HP C Compiler
>  # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
> diff --git a/libiberty/configure.ac b/libiberty/configure.ac
> index 922aa86..9f2d661 100644
> --- a/libiberty/configure.ac
> +++ b/libiberty/configure.ac
> @@ -272,6 +272,8 @@ AC_HEADER_TIME
>
>  libiberty_AC_DECLARE_ERRNO
>
> +AC_DEFINE(_GNU_SOURCE)
> +
>  # Determine sizes of some types.
>  AC_CHECK_SIZEOF([int])
>  AC_CHECK_SIZEOF([long])
> diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
> index 789fa05..4e73a2d 100644
> --- a/libiberty/floatformat.c
> +++ b/libiberty/floatformat.c
> @@ -19,7 +19,9 @@ along with this program; if not, write to the Free Software
>  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
> 02110-1301, USA.  */
>
>  /* This is needed to pick up the NAN macro on some systems.  */
> +#ifndef _GNU_SOURCE
>  #define _GNU_SOURCE
> +#endif
>
>  #ifdef HAVE_CONFIG_H
>  #include "config.h"
>
> On Tue, May 19, 2015 at 11:15 AM, Ian Lance Taylor <iant@google.com> wrote:
>> On Tue, May 19, 2015 at 11:08 AM, Yunlian Jiang <yunlian@google.com> wrote:
>>>
>>> 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.
>>
>> Probably if HAVE_DECL_ASPRINTF is not defined at all, we should not
>> declare asprintf in libiberty.h.
>>
>> Ian

  reply	other threads:[~2015-05-20 19:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-28 22:30 Yunlian Jiang
2015-05-01 22:45 ` Ian Lance Taylor
2015-05-01 23:45   ` Yunlian Jiang
2015-05-02 18:58     ` Ian Lance Taylor
2015-05-04 22:49       ` Yunlian Jiang
2015-05-05  0:30         ` Ian Lance Taylor
2015-05-18 23:52           ` Yunlian Jiang
2015-05-19  0:15             ` Ian Lance Taylor
2015-05-19 18:15               ` Yunlian Jiang
2015-05-19 18:16                 ` Ian Lance Taylor
2015-05-20 18:28                   ` Yunlian Jiang
2015-05-20 20:15                     ` Ian Lance Taylor [this message]
2015-05-20 23:27                       ` Yunlian Jiang
2015-05-22 21:25                         ` Ian Lance Taylor
2015-05-19 18:16                 ` DJ Delorie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKOQZ8wmD7Fk7oLUbYccCAQTgdOj1jHDgGJ7k2nhO0msGzJPpQ@mail.gmail.com \
    --to=iant@google.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=yunlian@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).