public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* GDB AIX build broken
@ 2016-10-24 22:40 David Edelsohn
  2016-10-24 22:46 ` Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2016-10-24 22:40 UTC (permalink / raw)
  To: GDB Patches, Tom Tromey, Pedro Alves

GDB build on AIX is broken due to a recent commit.

g++ -g -O2   -I. -I/home/dje/src/binutils-gdb/gdb
-I/home/dje/src/binutils-gdb/gdb/common
-I/home/dje/src/binutils-gdb/gdb/config
-DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
-I/home/dje/src/binutils-gdb/gdb/../include/opcode
-I/home/dje/src/binutils-gdb/gdb/../opcodes/..
-I/home/dje/src/binutils-gdb/gdb/../readline/..
-I/home/dje/src/binutils-gdb/gdb/../zlib -I../bfd
-I/home/dje/src/binutils-gdb/gdb/../bfd
-I/home/dje/src/binutils-gdb/gdb/../include -I../libdecnumber
-I/home/dje/src/binutils-gdb/gdb/../libdecnumber
-I/home/dje/src/binutils-gdb/gdb/gnulib/import -Ibuild-gnulib/import
-DTUI=1  -Wall -Wpointer-arith -Wno-unused -Wunused-value
-Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body
-Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare
-Wno-write-strings -Wno-narrowing -Wformat-nonliteral  -c -o buffer.o
-MT buffer.o -MMD -MP -MF .deps/buffer.Tpo
/home/dje/src/binutils-gdb/gdb/common/buffer.c
/home/dje/src/binutils-gdb/gdb/common/buffer.c: In function 'void
buffer_xml_printf(buffer*, const char*, ...)':
/home/dje/src/binutils-gdb/gdb/common/buffer.c:133:27: error: expected
')' before 'PRId64'
         sprintf (str, "%" PRId64,
                           ^~~~~~
/home/dje/src/binutils-gdb/gdb/common/buffer.c:134:43: warning:
spurious trailing '%' in format [-Wformat=]
           (int64_t) va_arg (ap, long long));
                                           ^
/home/dje/src/binutils-gdb/gdb/common/buffer.c:134:43: warning: too
many arguments for format [-Wformat-extra-args]
/home/dje/src/binutils-gdb/gdb/common/buffer.c:137:27: error: expected
')' before 'PRIu64'
         sprintf (str, "%" PRIu64,
                           ^~~~~~
/home/dje/src/binutils-gdb/gdb/common/buffer.c:138:53: warning:
spurious trailing '%' in format [-Wformat=]
           (uint64_t) va_arg (ap, unsigned long long));
                                                     ^
/home/dje/src/binutils-gdb/gdb/common/buffer.c:138:53: warning: too
many arguments for format [-Wformat-extra-args]
/home/dje/src/binutils-gdb/gdb/common/buffer.c:141:27: error: expected
')' before 'PRIx64'
         sprintf (str, "%" PRIx64,
                           ^~~~~~
/home/dje/src/binutils-gdb/gdb/common/buffer.c:142:53: warning:
spurious trailing '%' in format [-Wformat=]
           (uint64_t) va_arg (ap, unsigned long long));
                                                     ^
/home/dje/src/binutils-gdb/gdb/common/buffer.c:142:53: warning: too
many arguments for format [-Wformat-extra-args]
/home/dje/src/binutils-gdb/gdb/common/buffer.c:145:27: error: expected
')' before 'PRIo64'
         sprintf (str, "%" PRIo64,
                           ^~~~~~
/home/dje/src/binutils-gdb/gdb/common/buffer.c:146:53: warning:
spurious trailing '%' in format [-Wformat=]
           (uint64_t) va_arg (ap, unsigned long long));
                                                     ^
/home/dje/src/binutils-gdb/gdb/common/buffer.c:146:53: warning: too
many arguments for format [-Wformat-extra-args]

Errors with PRIxxx macros normally mean a problem with header file
inclusion.  for example, gdb/btrace.c, which also uses PRIxxx macros,
builds without error.

- David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-24 22:40 GDB AIX build broken David Edelsohn
@ 2016-10-24 22:46 ` Pedro Alves
  2016-10-24 22:53   ` David Edelsohn
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-24 22:46 UTC (permalink / raw)
  To: David Edelsohn, GDB Patches, Tom Tromey

[fixed Tom's address]

On 10/24/2016 11:40 PM, David Edelsohn wrote:
> GDB build on AIX is broken due to a recent commit.
> 

Which commit?  Maybe the gnulib update?  Is this a clean
build from scratch?

> /home/dje/src/binutils-gdb/gdb/common/buffer.c
> /home/dje/src/binutils-gdb/gdb/common/buffer.c: In function 'void
> buffer_xml_printf(buffer*, const char*, ...)':
> /home/dje/src/binutils-gdb/gdb/common/buffer.c:133:27: error: expected
> ')' before 'PRId64'
>          sprintf (str, "%" PRId64,
>                            ^~~~~~

> Errors with PRIxxx macros normally mean a problem with header file
> inclusion.  for example, gdb/btrace.c, which also uses PRIxxx macros,
> builds without error.

Sounds like what you'd get if PRId64 is not defined in that
compilation unit, somehow.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-24 22:46 ` Pedro Alves
@ 2016-10-24 22:53   ` David Edelsohn
  2016-10-24 23:00     ` Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2016-10-24 22:53 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB Patches, Tom Tromey

On Mon, Oct 24, 2016 at 6:46 PM, Pedro Alves <palves@redhat.com> wrote:
> [fixed Tom's address]
>
> On 10/24/2016 11:40 PM, David Edelsohn wrote:
>> GDB build on AIX is broken due to a recent commit.
>>
>
> Which commit?  Maybe the gnulib update?  Is this a clean
> build from scratch?

I have no idea which commit.  It probably was a bad idea to completely
disrupt the GDB Buildbots while disruptively converting GDB to C++.

>
>> /home/dje/src/binutils-gdb/gdb/common/buffer.c
>> /home/dje/src/binutils-gdb/gdb/common/buffer.c: In function 'void
>> buffer_xml_printf(buffer*, const char*, ...)':
>> /home/dje/src/binutils-gdb/gdb/common/buffer.c:133:27: error: expected
>> ')' before 'PRId64'
>>          sprintf (str, "%" PRId64,
>>                            ^~~~~~
>
>> Errors with PRIxxx macros normally mean a problem with header file
>> inclusion.  for example, gdb/btrace.c, which also uses PRIxxx macros,
>> builds without error.
>
> Sounds like what you'd get if PRId64 is not defined in that
> compilation unit, somehow.

First, strangely, gdb/common/buffer.c uses

#include "inttypes.h"

with quotes, not brackets.  I can't find a local definition of that header file.

It seems to be much happier with <inttypes.h> included first

diff --git a/gdb/common/buffer.c b/gdb/common/buffer.c
index e9eee09..a989024 100644
--- a/gdb/common/buffer.c
+++ b/gdb/common/buffer.c
@@ -17,10 +17,10 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

+#include <inttypes.h>
 #include "common-defs.h"
 #include "xml-utils.h"
 #include "buffer.h"
-#include "inttypes.h"

Thanks, David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-24 22:53   ` David Edelsohn
@ 2016-10-24 23:00     ` Pedro Alves
  2016-10-25  0:13       ` David Edelsohn
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-24 23:00 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches, Tom Tromey

On 10/24/2016 11:52 PM, David Edelsohn wrote:
> On Mon, Oct 24, 2016 at 6:46 PM, Pedro Alves <palves@redhat.com> wrote:
>> [fixed Tom's address]
>>
>> On 10/24/2016 11:40 PM, David Edelsohn wrote:
>>> GDB build on AIX is broken due to a recent commit.
>>>
>>
>> Which commit?  Maybe the gnulib update?  Is this a clean
>> build from scratch?
> 
> I have no idea which commit.  

git bisect will tell.

> It probably was a bad idea to completely
> disrupt the GDB Buildbots while disruptively converting GDB to C++.

It's probably a bad idea to speculate and throw blame around.

> 
>>
>>> /home/dje/src/binutils-gdb/gdb/common/buffer.c
>>> /home/dje/src/binutils-gdb/gdb/common/buffer.c: In function 'void
>>> buffer_xml_printf(buffer*, const char*, ...)':
>>> /home/dje/src/binutils-gdb/gdb/common/buffer.c:133:27: error: expected
>>> ')' before 'PRId64'
>>>          sprintf (str, "%" PRId64,
>>>                            ^~~~~~
>>
>>> Errors with PRIxxx macros normally mean a problem with header file
>>> inclusion.  for example, gdb/btrace.c, which also uses PRIxxx macros,
>>> builds without error.
>>
>> Sounds like what you'd get if PRId64 is not defined in that
>> compilation unit, somehow.
> 
> First, strangely, gdb/common/buffer.c uses
> 
> #include "inttypes.h"
> 
> with quotes, not brackets.  I can't find a local definition of that header file.
> 
> It seems to be much happier with <inttypes.h> included first
> 
> diff --git a/gdb/common/buffer.c b/gdb/common/buffer.c
> index e9eee09..a989024 100644
> --- a/gdb/common/buffer.c
> +++ b/gdb/common/buffer.c
> @@ -17,10 +17,10 @@
>     You should have received a copy of the GNU General Public License
>     along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> 
> +#include <inttypes.h>
>  #include "common-defs.h"
>  #include "xml-utils.h"
>  #include "buffer.h"
> -#include "inttypes.h"

That's a hint, but it can't be the fix.  common-defs.h must be the
first file included.  I suspect that gnulib's inttypes.h
replacement logic is broken on AIX.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-24 23:00     ` Pedro Alves
@ 2016-10-25  0:13       ` David Edelsohn
  2016-10-25  0:31         ` Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2016-10-25  0:13 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB Patches

On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:

> That's a hint, but it can't be the fix.  common-defs.h must be the
> first file included.  I suspect that gnulib's inttypes.h
> replacement logic is broken on AIX.

The gnulib import definitely is the commit that caused the breakage.

Interestingly,

gdb/btrace.c uses

#include <inttypes.h>

while

gdb/common/buffer.c uses

#include "inttypes.h"

Also, I'm sorry if my earlier comments came across poorly.

Thanks, David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-25  0:13       ` David Edelsohn
@ 2016-10-25  0:31         ` Pedro Alves
  2016-10-25  0:50           ` Pedro Alves
  2016-10-25  0:51           ` GDB AIX build broken David Edelsohn
  0 siblings, 2 replies; 16+ messages in thread
From: Pedro Alves @ 2016-10-25  0:31 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 01:13 AM, David Edelsohn wrote:
> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
> 
>> That's a hint, but it can't be the fix.  common-defs.h must be the
>> first file included.  I suspect that gnulib's inttypes.h
>> replacement logic is broken on AIX.
> 
> The gnulib import definitely is the commit that caused the breakage.
> 
> Interestingly,
> 
> gdb/btrace.c uses
> 
> #include <inttypes.h>
> 
> while
> 
> gdb/common/buffer.c uses
> 
> #include "inttypes.h"

I can't imagine there being a real reason for that.

> 
> Also, I'm sorry if my earlier comments came across poorly.

Sorry if I misunderstood them.  Might have been lost in translation.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-25  0:31         ` Pedro Alves
@ 2016-10-25  0:50           ` Pedro Alves
  2016-10-25  1:08             ` David Edelsohn
  2016-10-25  0:51           ` GDB AIX build broken David Edelsohn
  1 sibling, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-25  0:50 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 01:31 AM, Pedro Alves wrote:
> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>
>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>> first file included.  I suspect that gnulib's inttypes.h
>>> replacement logic is broken on AIX.
>>
>> The gnulib import definitely is the commit that caused the breakage.

Could it be it's the commit after the import?  The one
that removes __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS from
common-defs.h?

Looking at the import (49e4877c5487), we see that stdint.h
now relies on a new limits.h replacement, which sounds suspicious.

# The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH:

+  LIMITS_H=limits.h
+   if test -n "$LIMITS_H"; then
+  GL_GENERATE_LIMITS_H_TRUE=
+  GL_GENERATE_LIMITS_H_FALSE='#'
+else
+  GL_GENERATE_LIMITS_H_TRUE='#'
+  GL_GENERATE_LIMITS_H_FALSE=


and it had this change:

--- a/gdb/gnulib/import/stdint.in.h
+++ b/gdb/gnulib/import/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2016 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
    This file is part of gnulib.
 
@@ -79,54 +79,51 @@
 #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
 #define _@GUARD_PREFIX@_STDINT_H
 
+/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
+   LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH.  */
+#include <limits.h>
+
+#if ! @HAVE_C99_STDINT_H@
+
 /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
    IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
    AIX 5.2 <sys/types.h> isn't needed and causes troubles.
    Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
    relies on the system <stdint.h> definitions, so include
    <sys/types.h> after @NEXT_STDINT_H@.  */
-#if @HAVE_SYS_TYPES_H@ && ! defined _AIX
-# include <sys/types.h>
-#endif
-
-/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
-   LONG_MIN, LONG_MAX, ULONG_MAX.  */
-#include <limits.h>
+# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
+#  include <sys/types.h>
+# endif
 

Note the new HAVE_C99_STDINT_H check.  The _AIX check
is also curious.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-25  0:31         ` Pedro Alves
  2016-10-25  0:50           ` Pedro Alves
@ 2016-10-25  0:51           ` David Edelsohn
  2016-10-25  1:10             ` Pedro Alves
  1 sibling, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2016-10-25  0:51 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB Patches

On Mon, Oct 24, 2016 at 8:31 PM, Pedro Alves <palves@redhat.com> wrote:
> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>
>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>> first file included.  I suspect that gnulib's inttypes.h
>>> replacement logic is broken on AIX.
>>
>> The gnulib import definitely is the commit that caused the breakage.

gnulib weaves between its header files and the system header files in
dangerous ways.  It incorrectly assumes that it's version of a header
file always will be seen before a system header file.  But a system
header file may include another system header file directly.


AIX inttypes.h protects the printf format macros with

#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)

gnulib inttypes.h helpfully provides

   /* Some pre-C++11 <stdint.h> implementations need this.  */
#  if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
#   define __STDC_FORMAT_MACROS 1
#  endif

#  include_next <inttypes.h>
# endif
#endif

However, the first header file included by buffer.c is common-defs.h.
common-defs.h includes stdio.h, which includes gnulib stdio.h

#include_next <stdio.h>

Now we're in AIX stdio.h.  AIX stdio.h includes sys/types.h.  AIX
sys/types.h includes inttypes.h.

Bam.  We now have included AIX inttypes.h without __STDC_FORMAT_MACROS defined.

Later when gnulib inttypes.h explicitly is included, with
__STDC_FORMAT_MACROS defined, it's too late because inttypes.h is
protected from multiple inclusion.

Should __STDC_FORMAT_MACROS be defined in gdb/common/common-defs.h and
gdb/defs.h (if btrace.c also is changed)?

Thanks, David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-25  0:50           ` Pedro Alves
@ 2016-10-25  1:08             ` David Edelsohn
  2016-10-25  1:22               ` Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2016-10-25  1:08 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB Patches

On Mon, Oct 24, 2016 at 8:50 PM, Pedro Alves <palves@redhat.com> wrote:
> On 10/25/2016 01:31 AM, Pedro Alves wrote:
>> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>>
>>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>>> first file included.  I suspect that gnulib's inttypes.h
>>>> replacement logic is broken on AIX.
>>>
>>> The gnulib import definitely is the commit that caused the breakage.
>
> Could it be it's the commit after the import?  The one
> that removes __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS from
> common-defs.h?

common-defs.h needs __STDC_FORMAT_MACROS defined before stdio.h is
included, as one possible solution.

Thanks, David

> Looking at the import (49e4877c5487), we see that stdint.h
> now relies on a new limits.h replacement, which sounds suspicious.
>
> # The substitute stdint.h needs the substitute limit.h's _GL_INTEGER_WIDTH:
>
> +  LIMITS_H=limits.h
> +   if test -n "$LIMITS_H"; then
> +  GL_GENERATE_LIMITS_H_TRUE=
> +  GL_GENERATE_LIMITS_H_FALSE='#'
> +else
> +  GL_GENERATE_LIMITS_H_TRUE='#'
> +  GL_GENERATE_LIMITS_H_FALSE=
>
>
> and it had this change:
>
> --- a/gdb/gnulib/import/stdint.in.h
> +++ b/gdb/gnulib/import/stdint.in.h
> @@ -1,4 +1,4 @@
> -/* Copyright (C) 2001-2002, 2004-2015 Free Software Foundation, Inc.
> +/* Copyright (C) 2001-2002, 2004-2016 Free Software Foundation, Inc.
>     Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
>     This file is part of gnulib.
>
> @@ -79,54 +79,51 @@
>  #if ! defined _@GUARD_PREFIX@_STDINT_H && ! defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H
>  #define _@GUARD_PREFIX@_STDINT_H
>
> +/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
> +   LONG_MIN, LONG_MAX, ULONG_MAX, _GL_INTEGER_WIDTH.  */
> +#include <limits.h>
> +
> +#if ! @HAVE_C99_STDINT_H@
> +
>  /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
>     IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
>     AIX 5.2 <sys/types.h> isn't needed and causes troubles.
>     Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
>     relies on the system <stdint.h> definitions, so include
>     <sys/types.h> after @NEXT_STDINT_H@.  */
> -#if @HAVE_SYS_TYPES_H@ && ! defined _AIX
> -# include <sys/types.h>
> -#endif
> -
> -/* Get SCHAR_MIN, SCHAR_MAX, UCHAR_MAX, INT_MIN, INT_MAX,
> -   LONG_MIN, LONG_MAX, ULONG_MAX.  */
> -#include <limits.h>
> +# if @HAVE_SYS_TYPES_H@ && ! defined _AIX
> +#  include <sys/types.h>
> +# endif
>
>
> Note the new HAVE_C99_STDINT_H check.  The _AIX check
> is also curious.
>
> Thanks,
> Pedro Alves
>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-25  0:51           ` GDB AIX build broken David Edelsohn
@ 2016-10-25  1:10             ` Pedro Alves
  0 siblings, 0 replies; 16+ messages in thread
From: Pedro Alves @ 2016-10-25  1:10 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 01:51 AM, David Edelsohn wrote:
> On Mon, Oct 24, 2016 at 8:31 PM, Pedro Alves <palves@redhat.com> wrote:
>> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>>
>>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>>> first file included.  I suspect that gnulib's inttypes.h
>>>> replacement logic is broken on AIX.
>>>
>>> The gnulib import definitely is the commit that caused the breakage.
> 
> gnulib weaves between its header files and the system header files in
> dangerous ways.  It incorrectly assumes that it's version of a header
> file always will be seen before a system header file.  But a system
> header file may include another system header file directly.

Sure, and if so, gnulib will be patched to handle it somehow.

> 
> 
> AIX inttypes.h protects the printf format macros with
> 
> #if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)

There you go.  See my other email.  This means AIX's
headers haven't been updated for C++11 yet.  C++11 overruled
C99's decision to require the __STDC_FORMAT_MACROS input macro,
and the C11 followed suit.

> 
> gnulib inttypes.h helpfully provides
> 
>    /* Some pre-C++11 <stdint.h> implementations need this.  */
> #  if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
> #   define __STDC_FORMAT_MACROS 1
> #  endif
> 
> #  include_next <inttypes.h>
> # endif
> #endif

Right, that old way of defining __STDC_FORMAT_MACROS isn't complete.
That's why I wrote the fix at:
https://lists.gnu.org/archive/html/bug-gnulib/2015-11/msg00010.html
That now defines __STDC_FORMAT_MACROS in config.h instead.  Now the
problem is that gnulib's configure runs with a C compiler,
not a C++ compiler, so my fix doesn't really make a difference.   I had
written that assuming we'd change to configure/build gnulib
with a C++ compiler, back then.

So the fix is to do what I had suggested here
<https://sourceware.org/ml/gdb-patches/2016-10/msg00522.html>:

~~~~~~
                                              If this causes a problem
    somewhere, we can re-define the macros higher up in the file, before
    system headers are included.
~~~~~~

> Should __STDC_FORMAT_MACROS be defined in gdb/common/common-defs.h and
> gdb/defs.h (if btrace.c also is changed)?

Exactly, almost.  Only common/common-defs.h should be changed.
defs.h includes common/common-defs.h first thing,
before system headers.  ("common" refers to the file being
shared between gdb and gdbserver.)

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: GDB AIX build broken
  2016-10-25  1:08             ` David Edelsohn
@ 2016-10-25  1:22               ` Pedro Alves
  2016-10-25 10:58                 ` [pushed] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again (Re: GDB AIX build broken) Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-25  1:22 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 02:08 AM, David Edelsohn wrote:
> On Mon, Oct 24, 2016 at 8:50 PM, Pedro Alves <palves@redhat.com> wrote:
>> On 10/25/2016 01:31 AM, Pedro Alves wrote:
>>> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>>>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>>>
>>>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>>>> first file included.  I suspect that gnulib's inttypes.h
>>>>> replacement logic is broken on AIX.
>>>>
>>>> The gnulib import definitely is the commit that caused the breakage.
>>
>> Could it be it's the commit after the import?  The one
>> that removes __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS from
>> common-defs.h?
> 
> common-defs.h needs __STDC_FORMAT_MACROS defined before stdio.h is
> included, as one possible solution.

I'll do this tomorrow.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [pushed] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again (Re: GDB AIX build broken)
  2016-10-25  1:22               ` Pedro Alves
@ 2016-10-25 10:58                 ` Pedro Alves
  2016-10-25 12:41                   ` David Edelsohn
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-25 10:58 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 02:22 AM, Pedro Alves wrote:
> On 10/25/2016 02:08 AM, David Edelsohn wrote:
>> On Mon, Oct 24, 2016 at 8:50 PM, Pedro Alves <palves@redhat.com> wrote:
>>> On 10/25/2016 01:31 AM, Pedro Alves wrote:
>>>> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>>>>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>>>>
>>>>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>>>>> first file included.  I suspect that gnulib's inttypes.h
>>>>>> replacement logic is broken on AIX.
>>>>>
>>>>> The gnulib import definitely is the commit that caused the breakage.
>>>
>>> Could it be it's the commit after the import?  The one
>>> that removes __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS from
>>> common-defs.h?
>>
>> common-defs.h needs __STDC_FORMAT_MACROS defined before stdio.h is
>> included, as one possible solution.
> 
> I'll do this tomorrow.

I've pushed the patch below to master.

From 28fe4f87e0b815f4c0d9b80e0a9f3e6a53c649b3 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 25 Oct 2016 11:47:18 +0100
Subject: [PATCH] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again.

Revert commit f6abaf7a4088 (gdb: no longer define
__STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS), with the tweak suggested
in that commit's log: the macros are now defined before any system
header is included.

This should fix AIX:
  https://sourceware.org/ml/gdb-patches/2016-10/msg00682.html

gdb/ChangeLog:
2016-10-25  Pedro Alves  <palves@redhat.com>

       * common/common-defs.h (__STDC_CONSTANT_MACROS)
       (__STDC_LIMIT_MACROS): Define.
---
 gdb/ChangeLog            |  5 +++++
 gdb/common/common-defs.h | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 5541086..40fab9b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2016-10-25  Pedro Alves  <palves@redhat.com>
+
+       * common/common-defs.h (__STDC_CONSTANT_MACROS)
+       (__STDC_LIMIT_MACROS): Define.
+
 2016-10-25  Yao Qi  <yao.qi@linaro.org>
 
 	PR gdb/20716
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 9b5d853..3d5ff18 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -27,6 +27,19 @@
 #include "build-gnulib/config.h"
 #endif
 
+/* From:
+    https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html
+
+   "On some hosts that predate C++11, when using C++ one must define
+   __STDC_CONSTANT_MACROS to make visible the definitions of constant
+   macros such as INTMAX_C, and one must define __STDC_LIMIT_MACROS to
+   make visible the definitions of limit macros such as INTMAX_MAX.".
+
+   Must do this before including any system header, since system
+   headers may include stdint.h.  */
+#define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-- 
2.5.5


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [pushed] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again (Re: GDB AIX build broken)
  2016-10-25 10:58                 ` [pushed] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again (Re: GDB AIX build broken) Pedro Alves
@ 2016-10-25 12:41                   ` David Edelsohn
  2016-10-25 12:48                     ` Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: David Edelsohn @ 2016-10-25 12:41 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB Patches

On Tue, Oct 25, 2016 at 6:57 AM, Pedro Alves <palves@redhat.com> wrote:
> On 10/25/2016 02:22 AM, Pedro Alves wrote:
>> On 10/25/2016 02:08 AM, David Edelsohn wrote:
>>> On Mon, Oct 24, 2016 at 8:50 PM, Pedro Alves <palves@redhat.com> wrote:
>>>> On 10/25/2016 01:31 AM, Pedro Alves wrote:
>>>>> On 10/25/2016 01:13 AM, David Edelsohn wrote:
>>>>>> On Mon, Oct 24, 2016 at 7:00 PM, Pedro Alves <palves@redhat.com> wrote:
>>>>>>
>>>>>>> That's a hint, but it can't be the fix.  common-defs.h must be the
>>>>>>> first file included.  I suspect that gnulib's inttypes.h
>>>>>>> replacement logic is broken on AIX.
>>>>>>
>>>>>> The gnulib import definitely is the commit that caused the breakage.
>>>>
>>>> Could it be it's the commit after the import?  The one
>>>> that removes __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS from
>>>> common-defs.h?
>>>
>>> common-defs.h needs __STDC_FORMAT_MACROS defined before stdio.h is
>>> included, as one possible solution.
>>
>> I'll do this tomorrow.
>
> I've pushed the patch below to master.
>
> From 28fe4f87e0b815f4c0d9b80e0a9f3e6a53c649b3 Mon Sep 17 00:00:00 2001
> From: Pedro Alves <palves@redhat.com>
> Date: Tue, 25 Oct 2016 11:47:18 +0100
> Subject: [PATCH] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again.
>
> Revert commit f6abaf7a4088 (gdb: no longer define
> __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS), with the tweak suggested
> in that commit's log: the macros are now defined before any system
> header is included.
>
> This should fix AIX:
>   https://sourceware.org/ml/gdb-patches/2016-10/msg00682.html
>
> gdb/ChangeLog:
> 2016-10-25  Pedro Alves  <palves@redhat.com>
>
>        * common/common-defs.h (__STDC_CONSTANT_MACROS)
>        (__STDC_LIMIT_MACROS): Define.

Hi, Pedro

Thanks, however...

The missing macro is __STDC_FORMAT_MACROS.  The macros that you
re-added were not causing problems on AIX and don't enable the printf
format macros in C++.

Thanks, David

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [pushed] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again (Re: GDB AIX build broken)
  2016-10-25 12:41                   ` David Edelsohn
@ 2016-10-25 12:48                     ` Pedro Alves
  2016-10-25 12:54                       ` [pushed] common/common-defs.h: Define __STDC_FORMAT_MACROS as well " Pedro Alves
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-25 12:48 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 01:41 PM, David Edelsohn wrote:

>> gdb/ChangeLog:
>> 2016-10-25  Pedro Alves  <palves@redhat.com>
>>
>>        * common/common-defs.h (__STDC_CONSTANT_MACROS)
>>        (__STDC_LIMIT_MACROS): Define.
> 
> Hi, Pedro
> 
> Thanks, however...
> 
> The missing macro is __STDC_FORMAT_MACROS.  The macros that you
> re-added were not causing problems on AIX and don't enable the printf
> format macros in C++.

Indeed, missed.  Will add that too shortly.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [pushed] common/common-defs.h: Define __STDC_FORMAT_MACROS as well (Re: GDB AIX build broken)
  2016-10-25 12:48                     ` Pedro Alves
@ 2016-10-25 12:54                       ` Pedro Alves
  2016-10-25 13:01                         ` David Edelsohn
  0 siblings, 1 reply; 16+ messages in thread
From: Pedro Alves @ 2016-10-25 12:54 UTC (permalink / raw)
  To: David Edelsohn; +Cc: GDB Patches

On 10/25/2016 01:48 PM, Pedro Alves wrote:
> On 10/25/2016 01:41 PM, David Edelsohn wrote:

>> Thanks, however...
>>
>> The missing macro is __STDC_FORMAT_MACROS.  The macros that you
>> re-added were not causing problems on AIX and don't enable the printf
>> format macros in C++.
> 
> Indeed, missed.  Will add that too shortly.

Done now.  Let me know how it goes.

From b30f354acb39f63bf3213673a0584119e63538b9 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 25 Oct 2016 13:50:20 +0100
Subject: [PATCH] common/common-defs.h: Define __STDC_FORMAT_MACROS as well

Ref: https://sourceware.org/ml/gdb-patches/2016-10/msg00694.html

gdb/ChangeLog:
2016-10-25  Pedro Alves  <palves@redhat.com>

	* common/common-defs.h (__STDC_FORMAT_MACROS): Define.
---
 gdb/ChangeLog            |  4 ++++
 gdb/common/common-defs.h | 12 ++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c2a8579..1f58821 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2016-10-25  Pedro Alves  <palves@redhat.com>
 
+	* common/common-defs.h (__STDC_FORMAT_MACROS): Define.
+
+2016-10-25  Pedro Alves  <palves@redhat.com>
+
 	* common/new-op.c: Add comment about -fsanitize=address.
 
 2016-10-25  Pedro Alves  <palves@redhat.com>
diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h
index 3d5ff18..8fbb4bf 100644
--- a/gdb/common/common-defs.h
+++ b/gdb/common/common-defs.h
@@ -35,10 +35,18 @@
    macros such as INTMAX_C, and one must define __STDC_LIMIT_MACROS to
    make visible the definitions of limit macros such as INTMAX_MAX.".
 
-   Must do this before including any system header, since system
-   headers may include stdint.h.  */
+   And:
+    https://www.gnu.org/software/gnulib/manual/html_node/inttypes_002eh.html
+
+   "On some hosts that predate C++11, when using C++ one must define
+   __STDC_FORMAT_MACROS to make visible the declarations of format
+   macros such as PRIdMAX."
+
+   Must do this before including any system header, since other system
+   headers may include stdint.h/inttypes.h.  */
 #define __STDC_CONSTANT_MACROS 1
 #define __STDC_LIMIT_MACROS 1
+#define __STDC_FORMAT_MACROS 1
 
 #include <stdarg.h>
 #include <stdio.h>
-- 
2.5.5


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [pushed] common/common-defs.h: Define __STDC_FORMAT_MACROS as well (Re: GDB AIX build broken)
  2016-10-25 12:54                       ` [pushed] common/common-defs.h: Define __STDC_FORMAT_MACROS as well " Pedro Alves
@ 2016-10-25 13:01                         ` David Edelsohn
  0 siblings, 0 replies; 16+ messages in thread
From: David Edelsohn @ 2016-10-25 13:01 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB Patches

On Tue, Oct 25, 2016 at 8:54 AM, Pedro Alves <palves@redhat.com> wrote:
> On 10/25/2016 01:48 PM, Pedro Alves wrote:
>> On 10/25/2016 01:41 PM, David Edelsohn wrote:
>
>>> Thanks, however...
>>>
>>> The missing macro is __STDC_FORMAT_MACROS.  The macros that you
>>> re-added were not causing problems on AIX and don't enable the printf
>>> format macros in C++.
>>
>> Indeed, missed.  Will add that too shortly.
>
> Done now.  Let me know how it goes.

buffer.c now compiles.

Thanks, David

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-10-25 13:01 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24 22:40 GDB AIX build broken David Edelsohn
2016-10-24 22:46 ` Pedro Alves
2016-10-24 22:53   ` David Edelsohn
2016-10-24 23:00     ` Pedro Alves
2016-10-25  0:13       ` David Edelsohn
2016-10-25  0:31         ` Pedro Alves
2016-10-25  0:50           ` Pedro Alves
2016-10-25  1:08             ` David Edelsohn
2016-10-25  1:22               ` Pedro Alves
2016-10-25 10:58                 ` [pushed] Define __STDC_CONSTANT_MACROS/__STDC_LIMIT_MACROS again (Re: GDB AIX build broken) Pedro Alves
2016-10-25 12:41                   ` David Edelsohn
2016-10-25 12:48                     ` Pedro Alves
2016-10-25 12:54                       ` [pushed] common/common-defs.h: Define __STDC_FORMAT_MACROS as well " Pedro Alves
2016-10-25 13:01                         ` David Edelsohn
2016-10-25  0:51           ` GDB AIX build broken David Edelsohn
2016-10-25  1:10             ` Pedro Alves

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).