bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Fix distinction of 32-bit/64-bit mode with xlc 13.1.3 on AIX
@ 2021-02-15  2:50 Bruno Haible
  2021-02-15  3:29 ` Jeffrey Walton
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2021-02-15  2:50 UTC (permalink / raw)
  To: bug-gnulib

Starting with xlc version 13, this compiler defines the preprocessor macro
_ARCH_PPC64 also in 32-bit builds. See:

$ xlc -qversion
IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72)
Version: 12.01.0000.0000
$ echo > empty.c ; xlc -qshowmacros=pre -E empty.c | grep ARCH_PPC
#define _ARCH_PPC 1

$ xlc -qversion
IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
Version: 13.01.0003.0006
$ echo > empty.c ; xlc -qshowmacros=pre -E empty.c | grep ARCH_PPC
#define _ARCH_PPCGR 1
#define _ARCH_PPC64GRSQ 1
#define _ARCH_PPC 1
#define _ARCH_PPC64GR 1
#define _ARCH_PPC64 1

So, in order to distinguish a 32-bit mode from a 64-bit mode, only the
following macros can be used:
  - defined in 32-bit mode only: _ILP32 __ILP32__
  - defined in 64-bit mode only: _LP64 __LP64__ __64BIT__

This patch fixes it.


2021-02-14  Bruno Haible  <bruno@clisp.org>

	Fix distinction of 32-bit/64-bit mode with xlc 13.1.3 on AIX.
	* m4/host-cpu-c-abi.m4 (gl_HOST_CPU_C_ABI, gl_HOST_CPU_C_ABI_32BIT):
	Test __LP64__ instead of _ARCH_PPC64.
	* m4/lib-ld.m4 (AC_LIB_PROG_LD): Likewise.
	* lib/stddef.in.h: Likewise.

diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index 6385892..ba6f903 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -51,7 +51,7 @@
 
 /* On AIX 7.2, with xlc in 64-bit mode, <stddef.h> defines max_align_t to a
    type with alignment 4, but 'long' has alignment 8.  */
-#  if defined _AIX && defined _ARCH_PPC64
+#  if defined _AIX && defined __LP64__
 #   if !GNULIB_defined_max_align_t
 #    ifdef _MAX_ALIGN_T
 /* /usr/include/stddef.h has already defined max_align_t.  Override it.  */
diff --git a/m4/host-cpu-c-abi.m4 b/m4/host-cpu-c-abi.m4
index 7dc830e..64e28b1 100644
--- a/m4/host-cpu-c-abi.m4
+++ b/m4/host-cpu-c-abi.m4
@@ -1,4 +1,4 @@
-# host-cpu-c-abi.m4 serial 13
+# host-cpu-c-abi.m4 serial 14
 dnl Copyright (C) 2002-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -211,7 +211,7 @@ changequote([,])dnl
          # be generating 64-bit code.
          AC_COMPILE_IFELSE(
            [AC_LANG_SOURCE(
-              [[#if defined __powerpc64__ || defined _ARCH_PPC64
+              [[#if defined __powerpc64__ || defined __LP64__
                  int ok;
                 #else
                  error fail
@@ -605,7 +605,7 @@ changequote([,])dnl
            # be generating 64-bit code.
            AC_COMPILE_IFELSE(
              [AC_LANG_SOURCE(
-                [[#if defined __powerpc64__ || defined _ARCH_PPC64
+                [[#if defined __powerpc64__ || defined __LP64__
                    int ok;
                   #else
                    error fail
diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4
index aa07cb4..076358d 100644
--- a/m4/lib-ld.m4
+++ b/m4/lib-ld.m4
@@ -1,4 +1,4 @@
-# lib-ld.m4 serial 9
+# lib-ld.m4 serial 10
 dnl Copyright (C) 1996-2003, 2009-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -122,7 +122,7 @@ else
       *-*-aix*)
         AC_COMPILE_IFELSE(
           [AC_LANG_SOURCE(
-             [[#if defined __powerpc64__ || defined _ARCH_PPC64
+             [[#if defined __powerpc64__ || defined __LP64__
                 int ok;
                #else
                 error fail



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

* Re: Fix distinction of 32-bit/64-bit mode with xlc 13.1.3 on AIX
  2021-02-15  2:50 Fix distinction of 32-bit/64-bit mode with xlc 13.1.3 on AIX Bruno Haible
@ 2021-02-15  3:29 ` Jeffrey Walton
  2021-02-15 11:08   ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffrey Walton @ 2021-02-15  3:29 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib@gnu.org List

Hi Bruno,

On Sun, Feb 14, 2021 at 9:50 PM Bruno Haible <bruno@clisp.org> wrote:
>
> Starting with xlc version 13, this compiler defines the preprocessor macro
> _ARCH_PPC64 also in 32-bit builds. See:
>
> $ xlc -qversion
> IBM XL C/C++ for AIX, V12.1 (5765-J02, 5725-C72)
> Version: 12.01.0000.0000
> $ echo > empty.c ; xlc -qshowmacros=pre -E empty.c | grep ARCH_PPC
> #define _ARCH_PPC 1
>
> $ xlc -qversion
> IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
> Version: 13.01.0003.0006
> $ echo > empty.c ; xlc -qshowmacros=pre -E empty.c | grep ARCH_PPC
> #define _ARCH_PPCGR 1
> #define _ARCH_PPC64GRSQ 1
> #define _ARCH_PPC 1
> #define _ARCH_PPC64GR 1
> #define _ARCH_PPC64 1
>
> So, in order to distinguish a 32-bit mode from a 64-bit mode, only the
> following macros can be used:
>   - defined in 32-bit mode only: _ILP32 __ILP32__
>   - defined in 64-bit mode only: _LP64 __LP64__ __64BIT__

Are you sure that is correct? It almost sounds like the default is
32-bit, and you need an option to enable 64-bit.

According to the XL C/C++ manual for AIX (p. 507) [1]:

    _ARCH_PPC - Indicates that the application is
    targeted to run on any Power processor.

    _ARCH_PPC64 - Indicates that the application
    is targeted to run on Power processors with
    64-bit support.

And from the manual (p. 28):

    Compiler mode is set according to the last-found
    instance of the -q32or -q64 compiler options. If
    neither of these compiler options is set, the
    compiler mode is set by the value of the
    OBJECT_MODE environment variable. If the
    OBJECT_MODE environment variable is also not
    set, the compiler assumes32-bit compilation mode.

So it sounds like you are getting a 32-bit binary that runs on either
a 32-bit or 64-bit machine.

Jeff

[1] https://www.ibm.com/support/knowledgecenter/SSGH3R_13.1.3/com.ibm.compilers.aix.doc/compiler.pdf


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

* Re: Fix distinction of 32-bit/64-bit mode with xlc 13.1.3 on AIX
  2021-02-15  3:29 ` Jeffrey Walton
@ 2021-02-15 11:08   ` Bruno Haible
  0 siblings, 0 replies; 3+ messages in thread
From: Bruno Haible @ 2021-02-15 11:08 UTC (permalink / raw)
  To: noloader; +Cc: bug-gnulib

Hi Jeffrey,

> > So, in order to distinguish a 32-bit mode from a 64-bit mode, only the
> > following macros can be used:
> >   - defined in 32-bit mode only: _ILP32 __ILP32__
> >   - defined in 64-bit mode only: _LP64 __LP64__ __64BIT__
> 
> Are you sure that is correct? It almost sounds like the default is
> 32-bit, and you need an option to enable 64-bit.

Yes, for both compilers, 32-bit output is the default, and you need
option '-q64' in order to produce 64-bit output. I verified this using
the command 'file a.out'.

>     compiler mode is set by the value of the
>     OBJECT_MODE environment variable. If the
>     OBJECT_MODE environment variable is also not
>     set, the compiler assumes32-bit compilation mode.

I don't have the environment variable OBJECT_MODE set.

> According to the XL C/C++ manual for AIX (p. 507) [1]:
> 
>     _ARCH_PPC - Indicates that the application is
>     targeted to run on any Power processor.
> 
>     _ARCH_PPC64 - Indicates that the application
>     is targeted to run on Power processors with
>     64-bit support.

The new compiler's behaviour does not contradict this documentation.

Bruno



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

end of thread, other threads:[~2021-02-15 11:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15  2:50 Fix distinction of 32-bit/64-bit mode with xlc 13.1.3 on AIX Bruno Haible
2021-02-15  3:29 ` Jeffrey Walton
2021-02-15 11:08   ` Bruno Haible

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