From patchwork Fri Feb 27 16:22:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 444334 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 27266140119 for ; Sat, 28 Feb 2015 03:23:11 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xAlKp3gd; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=aPd9WrvJkVsc1SaIb+UsQbSl+F8W/8Eeh+Vys5QbcR8jmH5svsCWJ wThHUiXPZ95yhcCfGyW5b0brqFXRJRdpsQDJV10fl+jS59UWXPVfQ3aOeqr2/MCT gde/fXY3V+8ZWpzPcuggi4Fqy1wFqtYgTeCVufTxN1PLysOQjTphPQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=default; bh=qhSxEzTdSeGftdnVf9mvssROTH4=; b=xAlKp3gdjV1aK4jxIX5cGaOy9lSe jDnZ67DXYs4UiSS02O/9mNM6gq573846e4L2JxPg5/EOF7jAGUID1CuVNWgIW69j nBT1ZXla4MZk8EoCMfXRGV7FmoCXdzdLKvUcKTKk2nBcgxrgVHn9S2i8aMUnzL4O leb7yWf4NqDT/xA= Received: (qmail 114786 invoked by alias); 27 Feb 2015 16:23:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 113880 invoked by uid 89); 27 Feb 2015 16:23:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 27 Feb 2015 16:22:59 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1RGMwlS010326 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Feb 2015 11:22:58 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1RGMu4g005735; Fri, 27 Feb 2015 11:22:57 -0500 Message-ID: <54F099E0.6060509@redhat.com> Date: Fri, 27 Feb 2015 16:22:56 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org CC: GCC Patches Subject: Re: [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it References: <1423524046-20605-1-git-send-email-palves@redhat.com> <1423524046-20605-2-git-send-email-palves@redhat.com> In-Reply-To: <1423524046-20605-2-git-send-email-palves@redhat.com> On 02/09/2015 11:20 PM, Pedro Alves wrote: > Converting GDB to be a C++ program, I stumbled on 'basename' issues, > like: > ... > So I thought of adding a m4 file that projects that use libiberty can > source to pull in the autoconf checks that libiberty needs done in > order to use its public headers. > > Turns out that this has already happened. Since I first wrote this a > few months back, libiberty gained more HAVE_DECL_FOO checks even, for > the strtol & friends replacements. > > Are the libiberty changes OK? I moved the libiberty.m4 patch to the gdb/ directory instead, and pushed it, as below, in order to unblock the GDB C++ conversion series, and make it easier for others to help with the conversion as well. I put a libiberty.m4 patch series here: https://github.com/palves/gdb/tree/palves/libiberty_m4 that converts gas, gold, ld, gdb and libiberty/ itself to use libiberty/libiberty.m4. If people think that's a good idea, I can post it at some point. ---- From 07697489f4587e41f4f63aa526c1bd7d2fcd5494 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 27 Feb 2015 15:52:02 +0000 Subject: [PATCH] Create libiberty.m4, have GDB and GDBserver use it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Converting GDB to be a C++ program, I stumbled on 'basename' issues, like: src/gdb/../include/ansidecl.h:169:64: error: new declaration ‘char* basename(const char*)’ /usr/include/string.h:597:26: error: ambiguates old declaration ‘const char* basename(const char*)’ which I believe led to this bit in gold's configure.ac: dnl We have to check these in C, not C++, because autoconf generates dnl tests which have no type information, and current glibc provides dnl multiple declarations of functions like basename when compiling dnl with C++. AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp]) These checks IIUC intend to generate all the HAVE_DECL_FOO symbols that libiberty.h and ansidecl.h check. GDB is missing these checks currently, which results in the conflict shown above. This adds an m4 file that both GDB and GDBserver's configury use to pull in the autoconf checks that libiberty clients needs done in order to use these libiberty.h/ansidecl.h. gdb/ChangeLog: 2015-02-27 Pedro Alves * libiberty.m4: New file. * acinclude.m4: Include libiberty.m4. * configure.ac: Call libiberty_INIT. * config.in, configure: Regenerate. gdb/gdbserver/ 2015-02-27 Pedro Alves * acinclude.m4: Include libiberty.m4. * configure.ac: Call libiberty_INIT. * config.in, configure: Regenerate. --- gdb/ChangeLog | 7 + gdb/gdbserver/ChangeLog | 6 + gdb/acinclude.m4 | 3 + gdb/config.in | 45 ++++++ gdb/configure | 269 +++++++++++++++++++++++++++-------- gdb/configure.ac | 2 + gdb/gdbserver/acinclude.m4 | 3 + gdb/gdbserver/config.in | 41 ++++++ gdb/gdbserver/configure | 339 +++++++++++++++++++++++++++++++++++++++++++++ gdb/gdbserver/configure.ac | 2 + gdb/libiberty.m4 | 31 +++++ 11 files changed, 694 insertions(+), 54 deletions(-) create mode 100644 gdb/libiberty.m4 diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7d3b1ce..dfaad27 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2015-02-27 Pedro Alves + + * libiberty.m4: New file. + * acinclude.m4: Include libiberty.m4. + * configure.ac: Call libiberty_INIT. + * config.in, configure: Regenerate. + 2015-02-27 Andreas Arnez * s390-linux-tdep.c (s390_gcc_target_options): Not just handle diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 6bb8950..28b582f 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,9 @@ +2015-02-27 Pedro Alves + + * acinclude.m4: Include libiberty.m4. + * configure.ac: Call libiberty_INIT. + * config.in, configure: Regenerate. + 2015-02-26 Pedro Alves * linux-low.c (linux_wait_1): When incrementing the PC past a diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 1f0b574..0ad90e7 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -57,6 +57,9 @@ sinclude([../config/zlib.m4]) m4_include([common/common.m4]) +dnl For libiberty_INIT. +m4_include(libiberty.m4) + ## ----------------------------------------- ## ## ANSIfy the C compiler whenever possible. ## ## From Franc,ois Pinard ## diff --git a/gdb/config.in b/gdb/config.in index 806cbac..4aaadb5 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -85,6 +85,17 @@ you don't. */ #undef HAVE_DECL_ADDR_NO_RANDOMIZE +/* Define to 1 if you have the declaration of `asprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_ASPRINTF + +/* Define to 1 if you have the declaration of `basename(char *)', and to 0 if + you don't. */ +#undef HAVE_DECL_BASENAME + +/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ +#undef HAVE_DECL_FFS + /* Define to 1 if you have the declaration of `free', and to 0 if you don't. */ #undef HAVE_DECL_FREE @@ -117,6 +128,34 @@ */ #undef HAVE_DECL_STRSTR +/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't. + */ +#undef HAVE_DECL_STRTOL + +/* Define to 1 if you have the declaration of `strtoll', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOLL + +/* Define to 1 if you have the declaration of `strtoul', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOUL + +/* Define to 1 if you have the declaration of `strtoull', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOULL + +/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you + don't. */ +#undef HAVE_DECL_STRVERSCMP + +/* Define to 1 if you have the declaration of `vasprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_VASPRINTF + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_VSNPRINTF + /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H @@ -225,6 +264,9 @@ /* Define to 1 if the compiler supports long double. */ #undef HAVE_LONG_DOUBLE +/* Define to 1 if the system has the type `long long'. */ +#undef HAVE_LONG_LONG + /* Define if has lwpid_t. */ #undef HAVE_LWPID_T @@ -635,6 +677,9 @@ /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG +/* The size of `long long', as computed by sizeof. */ +#undef SIZEOF_LONG_LONG + /* The size of `unsigned long', as computed by sizeof. */ #undef SIZEOF_UNSIGNED_LONG diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4 index 744871a..e5f4b76 100644 --- a/gdb/gdbserver/acinclude.m4 +++ b/gdb/gdbserver/acinclude.m4 @@ -20,6 +20,9 @@ dnl anything else in gdbserver. m4_include(../../config/codeset.m4) m4_include(../common/common.m4) +dnl For libiberty_INIT. +m4_include(../libiberty.m4) + dnl Check for existence of a type $1 in libthread_db.h dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4. diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 8f68ed2..8114628 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -22,10 +22,25 @@ you don't. */ #undef HAVE_DECL_ADDR_NO_RANDOMIZE +/* Define to 1 if you have the declaration of `asprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_ASPRINTF + +/* Define to 1 if you have the declaration of `basename(char *)', and to 0 if + you don't. */ +#undef HAVE_DECL_BASENAME + +/* Define to 1 if you have the declaration of `ffs', and to 0 if you don't. */ +#undef HAVE_DECL_FFS + /* Define to 1 if you have the declaration of `perror', and to 0 if you don't. */ #undef HAVE_DECL_PERROR +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_SNPRINTF + /* Define to 1 if you have the declaration of `strerror', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR @@ -34,6 +49,26 @@ */ #undef HAVE_DECL_STRSTR +/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't. + */ +#undef HAVE_DECL_STRTOL + +/* Define to 1 if you have the declaration of `strtoll', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOLL + +/* Define to 1 if you have the declaration of `strtoul', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOUL + +/* Define to 1 if you have the declaration of `strtoull', and to 0 if you + don't. */ +#undef HAVE_DECL_STRTOULL + +/* Define to 1 if you have the declaration of `strverscmp', and to 0 if you + don't. */ +#undef HAVE_DECL_STRVERSCMP + /* Define to 1 if you have the declaration of `vasprintf', and to 0 if you don't. */ #undef HAVE_DECL_VASPRINTF @@ -96,6 +131,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H +/* Define to 1 if the system has the type `long long'. */ +#undef HAVE_LONG_LONG + /* Define if has lwpid_t. */ #undef HAVE_LWPID_T @@ -253,6 +291,9 @@ /* Bug reporting address */ #undef REPORT_BUGS_TO +/* The size of `long long', as computed by sizeof. */ +#undef SIZEOF_LONG_LONG + /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index f883adc..60636f7 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -193,6 +193,8 @@ LIBS="$LIBS -ldl" AC_CHECK_FUNCS(dladdr) LIBS="$old_LIBS" +libiberty_INIT + AC_CHECK_DECLS([strerror, perror, vasprintf, vsnprintf]) AC_CHECK_TYPES(socklen_t, [], [], diff --git a/gdb/libiberty.m4 b/gdb/libiberty.m4 new file mode 100644 index 0000000..5655e07 --- /dev/null +++ b/gdb/libiberty.m4 @@ -0,0 +1,31 @@ +dnl Bits libiberty clients must do on their autoconf step. +dnl +dnl Copyright (C) 2012-2015 Free Software Foundation, Inc. +dnl +dnl This file is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; see the file COPYING3. If not see +dnl . +dnl + +dnl Checks for declarations ansidecl.h and libiberty.h themselves +dnl check with HAVE_DECL_XXX, etc. + +AC_DEFUN([libiberty_INIT], +[ + # Check for presence and size of long long. + AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)]) + + AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf]) + AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull]) + AC_CHECK_DECLS([strverscmp]) +])