public inbox for [email protected]
help / color / mirror / Atom feedRe: AIX support
20+ messages / 5 participants
[nested] [flat]
* Re: AIX support
@ 2024-06-19 15:15 Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Heikki Linnakangas @ 2024-06-19 15:15 UTC (permalink / raw)
To: Srirama Kucherlapati <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; Heikki Linnakangas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
On 19/06/2024 17:55, Srirama Kucherlapati wrote:
> +/* Commenting for XLC
> + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
> + * expansions of ginCompareItemPointers() "long long" arithmetic. To take
> + * advantage of inlining, build a 64-bit PostgreSQL.
> +#if defined(__ILP32__) && defined(__IBMC__)
> +#define PG_FORCE_DISABLE_INLINE
> +#endif
> + */
This seems irrelevant.
> + * Ordinarily, we'd code the branches here using GNU-style local symbols, that
> + * is "1f" referencing "1:" and so on. But some people run gcc on AIX with
> + * IBM's assembler as backend, and IBM's assembler doesn't do local symbols.
> + * So hand-code the branch offsets; fortunately, all PPC instructions are
> + * exactly 4 bytes each, so it's not too hard to count.
Could you use GCC assembler to avoid this?
> @@ -662,6 +666,21 @@ tas(volatile slock_t *lock)
>
> #if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
>
> +#if defined(_AIX) /* AIX */
> +/*
> + * AIX (POWER)
> + */
> +#define HAS_TEST_AND_SET
> +
> +#include <sys/atomic_op.h>
> +
> +typedef int slock_t;
> +
> +#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
> +#endif /* _AIX */
> +
> +
> /* These are in sunstudio_(sparc|x86).s */
>
> #if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
What CPI/compiler/OS configuration is this for, exactly? Could we rely
on GCC-provided __sync_lock_test_and_set() builtin function instead?
> +# Allow platforms with buggy compilers to force restrict to not be
> +# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
> +# template.
Surely we don't need that anymore? Or is the compiler still buggy?
Do you still care about 32-bit binaries on AIX? If not, let's make that
the default in configure or a check for it, and remove the instructions
on building 32-bit binaries from the docs.
Please try hard to remove any changes from the diff that are not
absolutely necessary.
- Heikki
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
@ 2024-06-19 15:57 ` Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-06-19 15:57 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; Heikki Linnakangas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Thanks Hikki, for going through the changes.
> +/* Commenting for XLC
> + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
> + * expansions of ginCompareItemPointers() "long long" arithmetic. To take
> + * advantage of inlining, build a 64-bit PostgreSQL.
> +#if defined(__ILP32__) && defined(__IBMC__)
> +#define PG_FORCE_DISABLE_INLINE
> +#endif
> + */
I can remove these unwanted comments.
I have to analyze the changes for the rest of your comment and will get back to you.
Warm regards,
Sriram.
From: Heikki Linnakangas <[email protected]>
Date: Wednesday, 19 June 2024 at 8:45 PM
To: Srirama Kucherlapati <[email protected]>, Laurenz Albe <[email protected]>, Bruce Momjian <[email protected]>, Heikki Linnakangas <[email protected]>
Cc: Peter Eisentraut <[email protected]>, Alvaro Herrera <[email protected]>, [email protected] <[email protected]>, Noah Misch <[email protected]>, Michael Paquier <[email protected]>, Andres Freund <[email protected]>, Tom Lane <[email protected]>, Thomas Munro <[email protected]>, [email protected] <[email protected]>, [email protected] <[email protected]>
Subject: [EXTERNAL] Re: AIX support
On 19/06/2024 17:55, Srirama Kucherlapati wrote:
> +/* Commenting for XLC
> + * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
> + * expansions of ginCompareItemPointers() "long long" arithmetic. To take
> + * advantage of inlining, build a 64-bit PostgreSQL.
> +#if defined(__ILP32__) && defined(__IBMC__)
> +#define PG_FORCE_DISABLE_INLINE
> +#endif
> + */
This seems irrelevant.
> + * Ordinarily, we'd code the branches here using GNU-style local symbols, that
> + * is "1f" referencing "1:" and so on. But some people run gcc on AIX with
> + * IBM's assembler as backend, and IBM's assembler doesn't do local symbols.
> + * So hand-code the branch offsets; fortunately, all PPC instructions are
> + * exactly 4 bytes each, so it's not too hard to count.
Could you use GCC assembler to avoid this?
> @@ -662,6 +666,21 @@ tas(volatile slock_t *lock)
>
> #if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
>
> +#if defined(_AIX) /* AIX */
> +/*
> + * AIX (POWER)
> + */
> +#define HAS_TEST_AND_SET
> +
> +#include <sys/atomic_op.h>
> +
> +typedef int slock_t;
> +
> +#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
> +#endif /* _AIX */
> +
> +
> /* These are in sunstudio_(sparc|x86).s */
>
> #if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
What CPI/compiler/OS configuration is this for, exactly? Could we rely
on GCC-provided __sync_lock_test_and_set() builtin function instead?
> +# Allow platforms with buggy compilers to force restrict to not be
> +# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
> +# template.
Surely we don't need that anymore? Or is the compiler still buggy?
Do you still care about 32-bit binaries on AIX? If not, let's make that
the default in configure or a check for it, and remove the instructions
on building 32-bit binaries from the docs.
Please try hard to remove any changes from the diff that are not
absolutely necessary.
- Heikki
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-06-21 17:00 ` Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-06-21 17:00 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; Heikki Linnakangas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
We are continuing to work on the changes…
> Do you still care about 32-bit binaries on AIX? If not, let's make that
> the default in configure or a check for it, and remove the instructions
> on building 32-bit binaries from the docs.
As most of the products are moving towards 64bit, we will try to remove
this 32bit support.
Warm regards,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-08-14 03:31 ` Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-08-14 03:31 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; Heikki Linnakangas <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Hi Heikki & Team,
I tried to look at the assembly code changes with our team, in the below file.
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 29ac6cdcd9..69582f4ae7 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
static __inline__ int
tas(volatile slock_t *lock)
@@ -424,17 +430,15 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
" bne $+16 \n" /* branch to li %1,1 */
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
" beq $+12 \n" /* branch to lwsync */
" li %1,1 \n"
" b $+12 \n" /* branch to end of asm sequence */
" lwsync \n"
" li %1,0 \n"
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
For the changes in the above file, this code is very specific to power architecture we need to use the IBM Power specific asm code only, rather than using the GNU assembler. Also, all these asm specific code is under the macro __ppc__, which should not impact any other platforms. I see there is a GCC specific implementation (under this macro #if defined(HAVE_GCC__SYNC_INT32_TAS)) in the same file as well.
+#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
+#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
The above changes are specific to AIX kernel and it operates on fixed kernel memory. This is more like a compare_and_swap functionality with sync capability. For all the assemble code I think it would be better to use the IBM Power specific asm code to gain additional performance.
I was trying to understand here wrt to both the assemble changes if you are looking for anything specific to the architecture.
Attached is the patch for the previous comments, kindly please let me know your comments.
Warm regards,
Sriram.
Attachments:
[application/octet-stream] 0001-AIX-support-revert-changes-from-0b16bb8776bb.v3.patch (5.2K, 3-0001-AIX-support-revert-changes-from-0b16bb8776bb.v3.patch)
download | inline diff:
From 0d69a26fc1b52fb3e274176a83e7772b05bd7025 Mon Sep 17 00:00:00 2001
From: Sriram RK <[email protected]>
Date: Tue, 13 Aug 2024 08:19:25 -0500
Subject: [PATCH] AIX support revert changes from 0b16bb8776bb. Review comments
from Heikki
---
configure | 17 ++---------------
configure.ac | 5 +----
src/include/port/aix.h | 8 --------
src/include/storage/s_lock.h | 6 ------
src/template/aix | 12 ------------
5 files changed, 3 insertions(+), 45 deletions(-)
diff --git a/configure b/configure
index 03271f1861..f218b2e040 100755
--- a/configure
+++ b/configure
@@ -6849,12 +6849,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fno_strict_aliasing" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
fi
-
-elif test "$PORTNAME" = "aix"; then
- # AIX's xlc has to have strict aliasing turned off too
- # Igonoring the XLC falgs -qnoansialias, -qlonglong
-{ $as_echo_n "Running AIX gcc for now... " >&6; }
-
fi
# If the compiler knows how to hide symbols, add the switch needed for that to
@@ -7009,9 +7003,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fvisibility_inlines_hidden" = x"yes"; then
fi
have_visibility_attribute=$pgac_cv_prog_CC_cflags__fvisibility_hidden
-elif test "$PORTNAME" = "aix"; then
- # Note that xlc accepts -fvisibility=hidden as a file.
- { $as_echo_n "Running AIX gcc for now... " >&6; }
fi
if test "$have_visibility_attribute" = "yes"; then
@@ -14728,10 +14719,6 @@ fi
# spelling it understands, because it conflicts with
# __declspec(restrict). Therefore we define pg_restrict to the
# appropriate definition, which presumably won't conflict.
-#
-# Allow platforms with buggy compilers to force restrict to not be
-# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
-# template.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
if ${ac_cv_c_restrict+:} false; then :
@@ -14778,7 +14765,7 @@ _ACEOF
;;
esac
-if test "$ac_cv_c_restrict" = "no" -o "x$FORCE_DISABLE_RESTRICT" = "xyes"; then
+if test "$ac_cv_c_restrict" = "no"; then
pg_restrict=""
else
pg_restrict="$ac_cv_c_restrict"
@@ -17094,7 +17081,7 @@ else
/* end confdefs.h. */
/* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/configure.ac b/configure.ac
index 22069395a6..a059509cd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1646,11 +1646,8 @@ PGAC_TYPE_LOCALE_T
# __declspec(restrict). Therefore we define pg_restrict to the
# appropriate definition, which presumably won't conflict.
#
-# Allow platforms with buggy compilers to force restrict to not be
-# used by setting $FORCE_DISABLE_RESTRICT=yes in the relevant
-# template.
AC_C_RESTRICT
-if test "$ac_cv_c_restrict" = "no" -o "x$FORCE_DISABLE_RESTRICT" = "xyes"; then
+if test "$ac_cv_c_restrict" = "no" ; then
pg_restrict=""
else
pg_restrict="$ac_cv_c_restrict"
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
index c54c95d4a5..1c2d166791 100644
--- a/src/include/port/aix.h
+++ b/src/include/port/aix.h
@@ -4,11 +4,3 @@
#define CLASS_CONFLICT
#define DISABLE_XOPEN_NLS
-/* Commenting for XLC
- * "IBM XL C/C++ for AIX, V12.1" miscompiles, for 32-bit, some inline
- * expansions of ginCompareItemPointers() "long long" arithmetic. To take
- * advantage of inlining, build a 64-bit PostgreSQL.
-#if defined(__ILP32__) && defined(__IBMC__)
-#define PG_FORCE_DISABLE_INLINE
-#endif
- */
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 69582f4ae7..2f6eb5df2a 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -414,12 +414,6 @@ typedef unsigned int slock_t;
* an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
* But if the spinlock is in ordinary memory, we can use lwsync instead for
* better performance.
- *
- * Ordinarily, we'd code the branches here using GNU-style local symbols, that
- * is "1f" referencing "1:" and so on. But some people run gcc on AIX with
- * IBM's assembler as backend, and IBM's assembler doesn't do local symbols.
- * So hand-code the branch offsets; fortunately, all PPC instructions are
- * exactly 4 bytes each, so it's not too hard to count.
*/
static __inline__ int
tas(volatile slock_t *lock)
diff --git a/src/template/aix b/src/template/aix
index 903f8a8f8a..0a788676c0 100644
--- a/src/template/aix
+++ b/src/template/aix
@@ -1,17 +1,5 @@
# src/template/aix
-# Commenting for XLC
-# Set default options if using xlc. This formerly included -qsrcmsg, but that
-# option elicits internal compiler errors from xlc v16.1.0. Note: configure
-# will add -qnoansialias if the compiler accepts it, even if user specifies a
-# non-default CFLAGS setting.
-#if test "$GCC" != yes ; then
-# case $host_os in
-# *)
-# CFLAGS="-O2 -qmaxmem=16384"
-# ;;
-# esac
-
# Due to a compiler bug, see [email protected] for details,
# force restrict not to be used when compiling with xlc.
# FORCE_DISABLE_RESTRICT=yes
--
2.41.0
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-08-14 07:46 ` Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Heikki Linnakangas @ 2024-08-14 07:46 UTC (permalink / raw)
To: Srirama Kucherlapati <[email protected]>; Heikki Linnakangas <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
On 14/08/2024 06:31, Srirama Kucherlapati wrote:
> Hi Heikki & Team,
>
> I tried to look at the assembly code changes with our team, in the below
> file.
>
> diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
> index 29ac6cdcd9..69582f4ae7 100644
> --- a/src/include/storage/s_lock.h
> +++ b/src/include/storage/s_lock.h
> static __inline__ int
> tas(volatile slock_t *lock)
> @@ -424,17 +430,15 @@ tas(volatile slock_t *lock)
> __asm__ __volatile__(
> " lwarx %0,0,%3,1 \n"
> " cmpwi %0,0 \n"
> " bne $+16 \n" /* branch to li
> %1,1 */
> " addi %0,%0,1 \n"
> " stwcx. %0,0,%3 \n"
> " beq $+12 \n" /* branch to
> lwsync */
> " li %1,1 \n"
> " b $+12 \n" /* branch to end
> of asm sequence */
> " lwsync \n"
> " li %1,0 \n"
> : "=&b"(_t), "=r"(_res), "+m"(*lock)
> : "r"(lock)
> : "memory", "cc");
>
> For the changes in the above file, this code is very specific to power
> architecture we need to use the IBM Power specific asm code only, rather
> than using the GNU assembler. Also, all these asm specific code is under
> the macro __ppc__, which should not impact any other platforms. I see
> there is a GCC specific implementation (under this macro #if
> defined(HAVE_GCC__SYNC_INT32_TAS)) in the same file as well.
I'm sorry, I don't understand what you're saying here. Do you mean that
we don't need to do anything here, and the code we have in s_lock.h in
'master' now will work fine on AIX? Or do we need to (re-)do some
changes to support AIX again? If we only support GCC, can we use the
__sync_lock_test_and_set() builtin instead?
If any changes are required, please include them in the patch. That'll
make it clear what exactly you're proposing.
> +#define TAS(lock) _check_lock((slock_t *) (lock),
> 0, 1)
>
> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
>
> The above changes are specific to AIX kernel and it operates on fixed
> kernel memory. This is more like a compare_and_swap functionality with
> sync capability. For all the assemble code I think it would be better to
> use the IBM Power specific asm code to gain additional performance.
You mean we don't need the above? Ok, good.
> I was trying to understand here wrt to both the assemble changes if you
> are looking for anything specific to the architecture.
I don't know. You tell me what makes most sense on AIX / powerpc.
> Attached is the patch for the previous comments, kindly please let me
> know your comments.
Is this all that's needed to resurrect AIX support?
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
@ 2024-08-14 15:22 ` Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-08-14 15:22 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Hi Heikki,
I have attached the merged patch with all the changes, the earlier patch was
just only the changes specific to older review comments.
> I'm sorry, I don't understand what you're saying here. Do you mean that
> we don't need to do anything here, and the code we have in s_lock.h in
> 'master' now will work fine on AIX? Or do we need to (re-)do some
> changes to support AIX again? If we only support GCC, can we use the
> __sync_lock_test_and_set() builtin instead?
Here we need these changes for ppc. These changes are not for enabling
the AIX support, but this is implementing “Enhanced PowerPC Architecture”.
This routine is more of compare_and_increment, which is different from
GCC __sync_lock_test_and_set(). Also I tried to write a sample function to
check the assemble generated by __sync_lock_test_and_set(), which turned out to
be different set of assemble code.
> > +#define TAS(lock) _check_lock((slock_t *) (lock),
> > 0, 1)
> >
>> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
>>
> > The above changes are specific to AIX kernel and it operates on fixed
> > kernel memory. This is more like a compare_and_swap functionality with
> > sync capability. For all the assemble code I think it would be better to
> > use the IBM Power specific asm code to gain additional performance.
> You mean we don't need the above? Ok, good.
I mean this part of the code is needed as this is specific to AIX kernel memory
operation which is different from __sync_lock_test_and_set().
I would like to mention that the changes made in src/include/storage/s_lock.h
are pretty much required and need to be operated in assemble specific to IBM
Power architecture.
Warm regards,
Sriram.
Attachments:
[application/octet-stream] 0001-AIX-support-revert-the-changes-from-0b16bb8776bb8.v3.patch (43.7K, 3-0001-AIX-support-revert-the-changes-from-0b16bb8776bb8.v3.patch)
download | inline diff:
From 0ecf87244dea6530abed0d6f5172397e24fda922 Mon Sep 17 00:00:00 2001
From: Sriram RK <[email protected]>
Date: Mon, 20 May 2024 01:38:59 -0500
Subject: [PATCH] AIX support, revert the changes from 0b16bb8776bb8. Trim
AIX/XLC changes to support gcc only.
Review comments from Heikki.
---
Makefile | 2 -
configure | 37 +++---
configure.ac | 28 ++---
doc/src/sgml/dfunc.sgml | 19 +++
doc/src/sgml/installation.sgml | 118 +++++++++++++++++-
doc/src/sgml/runtime.sgml | 23 ++++
meson.build | 57 +++++----
src/Makefile.shlib | 29 +++++
src/backend/Makefile | 20 +++
src/backend/meson.build | 15 +++
src/backend/port/aix/mkldexport.sh | 61 +++++++++
src/backend/utils/error/elog.c | 2 +
src/backend/utils/misc/ps_status.c | 4 +-
src/bin/pg_basebackup/t/010_pg_basebackup.pl | 3 +-
src/bin/pg_verifybackup/t/008_untar.pl | 3 +-
src/bin/pg_verifybackup/t/010_client_untar.pl | 3 +-
src/include/c.h | 4 +-
src/include/port/aix.h | 6 +
src/include/storage/s_lock.h | 25 +++-
src/interfaces/libpq/Makefile | 2 +-
src/interfaces/libpq/meson.build | 5 +-
src/makefiles/Makefile.aix | 39 ++++++
src/port/README | 2 +-
src/port/strerror.c | 2 +
src/template/aix | 14 +++
src/test/regress/Makefile | 5 +
src/test/regress/expected/sanity_check.out | 29 +++++
src/test/regress/expected/test_setup.out | 4 +
src/test/regress/regress.c | 40 ++++++
src/test/regress/sql/sanity_check.sql | 26 ++++
src/test/regress/sql/test_setup.sql | 5 +
src/tools/gen_export.pl | 11 +-
src/tools/pginclude/headerscheck | 1 +
33 files changed, 555 insertions(+), 89 deletions(-)
create mode 100755 src/backend/port/aix/mkldexport.sh
create mode 100644 src/include/port/aix.h
create mode 100644 src/makefiles/Makefile.aix
create mode 100644 src/template/aix
diff --git a/Makefile b/Makefile
index 8a2ec9396b..9bc1a4ec17 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,6 @@
# AIX make defaults to building *every* target of the first rule. Start with
# a single-target, empty rule to make the other targets non-default.
-# (We don't support AIX anymore, but if someone tries to build on AIX anyway,
-# at least they'll get the instructions to run 'configure' first.)
all:
all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world check-world install-world installcheck-world:
diff --git a/configure b/configure
index 89644f2249..f218b2e040 100755
--- a/configure
+++ b/configure
@@ -2988,6 +2988,7 @@ else
# --with-template not given
case $host_os in
+ aix*) template=aix ;;
cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
@@ -6848,7 +6849,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fno_strict_aliasing" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
fi
-
fi
# If the compiler knows how to hide symbols, add the switch needed for that to
@@ -12860,7 +12860,8 @@ fi
fi
-# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS;
+# also, on AIX, we may need to have openssl in LIBS for this step.
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
@@ -16951,28 +16952,18 @@ _ACEOF
# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that long's alignment is at least as strong as
-# char, short, or int. Note that we intentionally do not consider any types
-# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too
-# much of a penalty for disk and memory space.
-
-MAX_ALIGNOF=$ac_cv_alignof_double
+# We assume long's alignment is at least as strong as char, short, or int;
+# but we must check long long (if it is being used for int64) and double.
+# Note that we intentionally do not consider any types wider than 64 bits,
+# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
+# for disk and memory space.
-if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long' is greater than the alignment of 'double'" "$LINENO" 5
+MAX_ALIGNOF=$ac_cv_alignof_long
+if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
+ MAX_ALIGNOF=$ac_cv_alignof_double
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long long int' is greater than the alignment of 'double'" "$LINENO" 5
+if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ; then
+ MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
fi
cat >>confdefs.h <<_ACEOF
@@ -17090,7 +17081,7 @@ else
/* end confdefs.h. */
/* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/configure.ac b/configure.ac
index c7322e292c..a059509cd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ PGAC_ARG_REQ(with, template, [NAME], [override operating system template],
# --with-template not given
case $host_os in
+ aix*) template=aix ;;
cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
@@ -1385,7 +1386,8 @@ if test "$with_zstd" = yes ; then
AC_CHECK_LIB(zstd, ZSTD_compress, [], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])])
fi
-# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS;
+# also, on AIX, we may need to have openssl in LIBS for this step.
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
@@ -1643,8 +1645,9 @@ PGAC_TYPE_LOCALE_T
# spelling it understands, because it conflicts with
# __declspec(restrict). Therefore we define pg_restrict to the
# appropriate definition, which presumably won't conflict.
+#
AC_C_RESTRICT
-if test "$ac_cv_c_restrict" = "no"; then
+if test "$ac_cv_c_restrict" = "no" ; then
pg_restrict=""
else
pg_restrict="$ac_cv_c_restrict"
@@ -1996,22 +1999,11 @@ fi
AC_CHECK_ALIGNOF(double)
# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that long's alignment is at least as strong as
-# char, short, or int. Note that we intentionally do not consider any types
-# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too
-# much of a penalty for disk and memory space.
-
-MAX_ALIGNOF=$ac_cv_alignof_double
+# We assume long's alignment is at least as strong as char, short, or int;
+# but we must check long long (if it is being used for int64) and double.
+# Note that we intentionally do not consider any types wider than 64 bits,
+# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
+# for disk and memory space.
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
AC_MSG_ERROR([alignment of 'long' is greater than the alignment of 'double'])
diff --git a/doc/src/sgml/dfunc.sgml b/doc/src/sgml/dfunc.sgml
index b94aefcd0c..554f9fac4c 100644
--- a/doc/src/sgml/dfunc.sgml
+++ b/doc/src/sgml/dfunc.sgml
@@ -202,4 +202,23 @@ gcc -G -o foo.so foo.o
server expects to find the shared library files.
</para>
+<!--
+Under AIX, object files are compiled normally but building the shared
+library requires a couple of steps. First, create the object file:
+.nf
+cc <other flags> -c foo.c
+.fi
+You must then create a symbol \*(lqexports\*(rq file for the object
+file:
+.nf
+mkldexport foo.o `pwd` > foo.exp
+.fi
+Finally, you can create the shared library:
+.nf
+ld <other flags> -H512 -T512 -o foo.so -e _nostart \e
+ -bI:.../lib/postgres.exp -bE:foo.exp foo.o \e
+ -lm -lc 2>/dev/null
+.fi
+ -->
+
</sect2>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1b32d5ca62..60e9a34a03 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -3401,7 +3401,7 @@ export MANPATH
<para>
<productname>PostgreSQL</productname> can be expected to work on current
versions of these operating systems: Linux, Windows,
- FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, Solaris, and illumos.
+ FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, AIX, Solaris, and illumos.
Other Unix-like systems may also work but are not currently
being tested. In most cases, all CPU architectures supported by
a given operating system will work. Look in
@@ -3445,6 +3445,122 @@ export MANPATH
installation issues.
</para>
+ <sect2 id="installation-notes-aix">
+ <title>AIX</title>
+
+ <indexterm zone="installation-notes-aix">
+ <primary>AIX</primary>
+ <secondary>installation on</secondary>
+ </indexterm>
+
+ <para>
+ You can use GCC to build <productname>PostgreSQL</productname>
+ on <productname>AIX</productname>.
+ </para>
+
+ <para>
+ <productname>AIX</productname> versions before 7.1 are no longer
+ tested nor supported by the <productname>PostgreSQL</productname>
+ community.
+ </para>
+
+ <sect3 id="installation-notes-aix-mem-management">
+ <title>Memory Management</title>
+ <!-- https://archives.postgresql.org/message-id/[email protected] -->
+
+ <para>
+ AIX can be somewhat peculiar with regards to the way it does
+ memory management. You can have a server with many multiples of
+ gigabytes of RAM free, but still get out of memory or address
+ space errors when running applications. One example
+ is loading of extensions failing with unusual errors.
+ For example, running as the owner of the PostgreSQL installation:
+<screen>
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process.
+</screen>
+ Running as a non-owner in the group possessing the PostgreSQL
+ installation:
+<screen>
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
+</screen>
+ Another example is out of memory errors in the PostgreSQL server
+ logs, with every memory allocation near or greater than 256 MB
+ failing.
+ </para>
+
+ <para>
+ The overall cause of all these problems is the default bittedness
+ and memory model used by the server process. By default, all
+ binaries built on AIX are 32-bit. This does not depend upon
+ hardware type or kernel in use. These 32-bit processes are
+ limited to 4 GB of memory laid out in 256 MB segments using one
+ of a few models. The default allows for less than 256 MB in the
+ heap as it shares a single segment with the stack.
+ </para>
+
+ <para>
+ In the case of the <literal>plperl</literal> example, above,
+ check your umask and the permissions of the binaries in your
+ PostgreSQL installation. The binaries involved in that example
+ were 32-bit and installed as mode 750 instead of 755. Due to the
+ permissions being set in this fashion, only the owner or a member
+ of the possessing group can load the library. Since it isn't
+ world-readable, the loader places the object into the process'
+ heap instead of the shared library segments where it would
+ otherwise be placed.
+ </para>
+
+ <para>
+ The <quote>ideal</quote> solution for this is to use a 64-bit
+ build of PostgreSQL, but that is not always practical, because
+ systems with 32-bit processors can build, but not run, 64-bit
+ binaries.
+ </para>
+
+ <para>
+ If a 32-bit binary is desired, set <symbol>LDR_CNTRL</symbol> to
+ <literal>MAXDATA=0x<replaceable>n</replaceable>0000000</literal>,
+ where 1 <= n <= 8, before starting the PostgreSQL server,
+ and try different values and <filename>postgresql.conf</filename>
+ settings to find a configuration that works satisfactorily. This
+ use of <symbol>LDR_CNTRL</symbol> tells AIX that you want the
+ server to have <symbol>MAXDATA</symbol> bytes set aside for the
+ heap, allocated in 256 MB segments. When you find a workable
+ configuration,
+ <command>ldedit</command> can be used to modify the binaries so
+ that they default to using the desired heap size. PostgreSQL can
+ also be rebuilt, passing <literal>configure
+ LDFLAGS="-Wl,-bmaxdata:0x<replaceable>n</replaceable>0000000"</literal>
+ to achieve the same effect.
+ </para>
+
+ <para>
+ For a 64-bit build, set <envar>OBJECT_MODE</envar> to 64 and
+ pass <literal>CC="gcc -maix64"</literal>
+ and <literal>LDFLAGS="-Wl,-bbigtoc"</literal>
+ to <command>configure</command>.
+ If you omit the export of
+ <envar>OBJECT_MODE</envar>, your build may fail with linker errors. When
+ <envar>OBJECT_MODE</envar> is set, it tells AIX's build utilities
+ such as <command>ar</command>, <command>as</command>, and <command>ld</command> what
+ type of objects to default to handling.
+ </para>
+
+ <para>
+ By default, overcommit of paging space can happen. While we have
+ not seen this occur, AIX will kill processes when it runs out of
+ memory and the overcommit is accessed. The closest to this that
+ we have seen is fork failing because the system decided that
+ there was not enough memory for another process. Like many other
+ parts of AIX, the paging space allocation method and
+ out-of-memory kill is configurable on a system- or process-wide
+ basis if this becomes a problem.
+ </para>
+ </sect3>
+ </sect2>
+
<sect2 id="installation-notes-cygwin">
<title>Cygwin</title>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 6047b8171d..64753d9c01 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -891,6 +891,29 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
<variablelist>
+ <varlistentry>
+ <term><systemitem class="osname">AIX</systemitem>
+ <indexterm><primary>AIX</primary><secondary>IPC configuration</secondary></indexterm>
+ </term>
+ <listitem>
+ <para>
+ It should not be necessary to do
+ any special configuration for such parameters as
+ <varname>SHMMAX</varname>, as it appears this is configured to
+ allow all memory to be used as shared memory. That is the
+ sort of configuration commonly used for other databases such
+ as <application>DB/2</application>.</para>
+
+ <para> It might, however, be necessary to modify the global
+ <command>ulimit</command> information in
+ <filename>/etc/security/limits</filename>, as the default hard
+ limits for file sizes (<varname>fsize</varname>) and numbers of
+ files (<varname>nofiles</varname>) might be too low.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
<varlistentry>
<term><systemitem class="osname">FreeBSD</systemitem>
<indexterm><primary>FreeBSD</primary><secondary>IPC configuration</secondary></indexterm>
diff --git a/meson.build b/meson.build
index 1c0579d5a6..f1ac154cdc 100644
--- a/meson.build
+++ b/meson.build
@@ -196,7 +196,26 @@ endif
# that purpose.
portname = host_system
-if host_system == 'cygwin'
+if host_system == 'aix'
+ library_path_var = 'LIBPATH'
+
+ export_file_format = 'aix'
+ export_fmt = '-Wl,-bE:@0@'
+ mod_link_args_fmt = ['-Wl,-bI:@0@']
+ mod_link_with_dir = 'libdir'
+ mod_link_with_name = '@[email protected]'
+
+ # M:SRE sets a flag indicating that an object is a shared library. Seems to
+ # work in some circumstances without, but required in others.
+ ldflags_sl += '-Wl,-bM:SRE'
+ ldflags_be += '-Wl,-brtllib'
+
+ # Native memset() is faster, tested on:
+ # - AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
+ # - AIX 5.3 ML3, gcc 4.0.1
+ memset_loop_limit = 0
+
+elif host_system == 'cygwin'
sema_kind = 'unnamed_posix'
cppflags += '-D_GNU_SOURCE'
dlsuffix = '.dll'
@@ -1490,11 +1509,11 @@ sizeof_long = cc.sizeof('long', args: test_c_args)
cdata.set('SIZEOF_LONG', sizeof_long)
if sizeof_long == 8
cdata.set('HAVE_LONG_INT_64', 1)
- pg_int64_type = 'long int'
+ cdata.set('PG_INT64_TYPE', 'long int')
cdata.set_quoted('INT64_MODIFIER', 'l')
elif sizeof_long == 4 and cc.sizeof('long long', args: test_c_args) == 8
cdata.set('HAVE_LONG_LONG_INT_64', 1)
- pg_int64_type = 'long long int'
+ cdata.set('PG_INT64_TYPE', 'long long int')
cdata.set_quoted('INT64_MODIFIER', 'll')
else
error('do not know how to get a 64bit int')
@@ -1508,31 +1527,15 @@ endif
# Determine memory alignment requirements for the basic C data types.
alignof_types = ['short', 'int', 'long', 'double']
+maxalign = 0
foreach t : alignof_types
align = cc.alignment(t, args: test_c_args)
+ if maxalign < align
+ maxalign = align
+ endif
cdata.set('ALIGNOF_@0@'.format(t.to_upper()), align)
endforeach
-
-# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that int64's alignment is at least as strong
-# as long, char, short, or int. Note that we intentionally do not consider
-# any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8
-# would be too much of a penalty for disk and memory space.
-alignof_double = cdata.get('ALIGNOF_DOUBLE')
-if cc.alignment(pg_int64_type, args: test_c_args) > alignof_double
- error('alignment of int64 is greater than the alignment of double')
-endif
-cdata.set('MAXIMUM_ALIGNOF', alignof_double)
+cdata.set('MAXIMUM_ALIGNOF', maxalign)
cdata.set('SIZEOF_VOID_P', cc.sizeof('void *', args: test_c_args))
cdata.set('SIZEOF_SIZE_T', cc.sizeof('size_t', args: test_c_args))
@@ -1581,7 +1584,7 @@ if cc.links('''
if not meson.is_cross_build()
r = cc.run('''
/* This must match the corresponding code in c.h: */
- #if defined(__GNUC__) || defined(__SUNPRO_C)
+ #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
@@ -2476,6 +2479,10 @@ endif
# conflict.
#
# We assume C99 support, so we don't need to make this conditional.
+#
+# XXX: Historically we allowed platforms to disable restrict in template
+# files, but that was only added for AIX when building with XLC, which we
+# don't support yet.
cdata.set('pg_restrict', '__restrict')
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index fa81f6ffdd..8ca51ca03f 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -106,6 +106,20 @@ ifdef SO_MAJOR_VERSION
override CPPFLAGS += -DSO_MAJOR_VERSION=$(SO_MAJOR_VERSION)
endif
+ifeq ($(PORTNAME), aix)
+ LINK.shared = $(COMPILER)
+ ifdef SO_MAJOR_VERSION
+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ endif
+ haslibarule = yes
+ # $(exports_file) is also usable as an import file
+ exports_file = lib$(NAME).exp
+ BUILD.exports = ( echo '\#! $(shlib)'; $(AWK) '/^[^\#]/ {printf "%s\n",$$1}' $< ) > $@
+ ifneq (,$(SHLIB_EXPORTS))
+ LINK.shared += -Wl,-bE:$(exports_file)
+ endif
+endif
+
ifeq ($(PORTNAME), darwin)
ifdef soname
# linkable library
@@ -254,6 +268,14 @@ $(stlib): $(OBJS) | $(SHLIB_PREREQS)
touch $@
endif #haslibarule
+# AIX wraps shared libraries inside a static library, can be used both
+# for static and shared linking
+ifeq ($(PORTNAME), aix)
+$(stlib): $(shlib)
+ rm -f $(stlib)
+ $(AR) $(AROPT) $(stlib) $(shlib)
+endif # aix
+
ifeq (,$(filter cygwin win32,$(PORTNAME)))
# Normal case
@@ -267,8 +289,11 @@ ifneq ($(shlib), $(shlib_major))
endif
# Make sure we have a link to a name without any version numbers
ifneq ($(shlib), $(shlib_bare))
+# except on AIX, where that's not a thing
+ifneq ($(PORTNAME), aix)
rm -f $(shlib_bare)
$(LN_S) $(shlib) $(shlib_bare)
+endif # aix
endif # shlib_bare
endif # shlib_major
@@ -376,6 +401,9 @@ install-lib-static: $(stlib) installdirs-lib
install-lib-shared: $(shlib) installdirs-lib
ifdef soname
+# we don't install $(shlib) on AIX
+# (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at)
+ifneq ($(PORTNAME), aix)
$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
@@ -391,6 +419,7 @@ ifneq ($(shlib), $(shlib_bare))
endif
endif # not win32
endif # not cygwin
+endif # not aix
ifneq (,$(findstring $(PORTNAME),win32 cygwin))
$(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
endif
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 6700aec039..954b14962f 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -62,12 +62,14 @@ all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
+ifneq ($(PORTNAME), aix)
postgres: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
endif
endif
+endif
ifeq ($(PORTNAME), cygwin)
@@ -94,6 +96,24 @@ libpostgres.a: postgres
endif # win32
+ifeq ($(PORTNAME), aix)
+
+postgres: $(POSTGRES_IMP)
+ $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
+
+# Linking to a single .o with -r is a lot faster than building a .a or passing
+# all objects to MKLDEXPORT.
+#
+# It looks alluring to use $(CC) -r instead of ld -r, but that doesn't
+# trivially work with gcc, due to gcc specific static libraries linked in with
+# -r.
+$(POSTGRES_IMP): $(OBJS)
+ ld -r -o SUBSYS.o $(call expand_subsys,$^)
+ $(MKLDEXPORT) SUBSYS.o . > $@
+ @rm -f SUBSYS.o
+
+endif # aix
+
$(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 436c04af08..8767aaba67 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -91,6 +91,21 @@ if cc.get_id() == 'msvc'
# be restricted to b_pch=true.
backend_link_with += postgres_lib
+elif host_system == 'aix'
+ # The '.' argument leads mkldexport.sh to emit "#! .", which refers to the
+ # main executable, allowing extension libraries to resolve their undefined
+ # symbols to symbols in the postgres binary.
+ postgres_imp = custom_target('postgres.imp',
+ command: [files('port/aix/mkldexport.sh'), '@INPUT@', '.'],
+ input: postgres_lib,
+ output: 'postgres.imp',
+ capture: true,
+ install: true,
+ install_dir: dir_lib,
+ build_by_default: false,
+ )
+ backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path())
+ backend_link_depends += postgres_imp
endif
backend_input = []
diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh
new file mode 100755
index 0000000000..adf3793e86
--- /dev/null
+++ b/src/backend/port/aix/mkldexport.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# mkldexport
+# create an AIX exports file from an object file
+#
+# src/backend/port/aix/mkldexport.sh
+#
+# Usage:
+# mkldexport objectfile [location]
+# where
+# objectfile is the current location of the object file.
+# location is the eventual (installed) location of the
+# object file (if different from the current
+# working directory).
+#
+# [This file comes from the Postgres 4.2 distribution. - ay 7/95]
+#
+# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp
+#
+
+# setting this to nm -B might be better
+# ... due to changes in AIX 4.x ...
+# ... let us search in different directories - Gerhard Reithofer
+if [ -x /usr/ucb/nm ]
+then NM=/usr/ucb/nm
+elif [ -x /usr/bin/nm ]
+then NM=/usr/bin/nm
+elif [ -x /usr/ccs/bin/nm ]
+then NM=/usr/ccs/bin/nm
+elif [ -x /usr/usg/bin/nm ]
+then NM=/usr/usg/bin/nm
+else echo "Fatal error: cannot find `nm' ... please check your installation."
+ exit 1
+fi
+
+CMDNAME=`basename $0`
+if [ -z "$1" ]; then
+ echo "Usage: $CMDNAME object [location]"
+ exit 1
+fi
+OBJNAME=`basename $1`
+if [ "`basename $OBJNAME`" != "`basename $OBJNAME .o`" ]; then
+ OBJNAME=`basename $OBJNAME .o`.so
+fi
+if [ -z "$2" ]; then
+ echo '#!'
+else
+ if [ "$2" = "." ]; then
+ # for the base executable (AIX 4.2 and up)
+ echo '#! .'
+ else
+ echo '#!' $2
+ fi
+fi
+$NM -BCg $1 | \
+ egrep ' [TDB] ' | \
+ sed -e 's/.* //' | \
+ egrep -v '\$' | \
+ sed -e 's/^[.]//' | \
+ sort | \
+ uniq
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index d91a85cb2d..7b51e94f4a 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -908,7 +908,9 @@ errcode_for_file_access(void)
/* Wrong object type or state */
case ENOTDIR: /* Not a directory */
case EISDIR: /* Is a directory */
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
case ENOTEMPTY: /* Directory not empty */
+#endif
edata->sqlerrcode = ERRCODE_WRONG_OBJECT_TYPE;
break;
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index 9da6377402..532eac31b4 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -50,7 +50,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
#define PS_USE_SETPROCTITLE_FAST
#elif defined(HAVE_SETPROCTITLE)
#define PS_USE_SETPROCTITLE
-#elif defined(__linux__) || defined(__sun) || defined(__darwin__)
+#elif defined(__linux__) || defined(_AIX) || defined(__sun) || defined(__darwin__)
#define PS_USE_CLOBBER_ARGV
#elif defined(WIN32)
#define PS_USE_WIN32
@@ -60,7 +60,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
/* Different systems want the buffer padded differently */
-#if defined(__linux__) || defined(__darwin__)
+#if defined(_AIX) || defined(__linux__) || defined(__darwin__)
#define PS_PADDING '\0'
#else
#define PS_PADDING ' '
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 2d4b75a6fe..ce936959c1 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -401,7 +401,8 @@ SKIP:
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/bin/pg_verifybackup/t/008_untar.pl b/src/bin/pg_verifybackup/t/008_untar.pl
index 7a09f3b75b..30d9f3f7f0 100644
--- a/src/bin/pg_verifybackup/t/008_untar.pl
+++ b/src/bin/pg_verifybackup/t/008_untar.pl
@@ -104,7 +104,8 @@ for my $tc (@test_configuration)
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/bin/pg_verifybackup/t/010_client_untar.pl b/src/bin/pg_verifybackup/t/010_client_untar.pl
index 8c076d46de..45010d79ac 100644
--- a/src/bin/pg_verifybackup/t/010_client_untar.pl
+++ b/src/bin/pg_verifybackup/t/010_client_untar.pl
@@ -134,7 +134,8 @@ for my $tc (@test_configuration)
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/include/c.h b/src/include/c.h
index dc1841346c..641cd9bdf1 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -182,7 +182,7 @@
#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
#endif
-/* GCC supports format attributes */
+/* GCC support format attributes */
#if defined(__GNUC__)
#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
@@ -192,7 +192,7 @@
#endif
/* GCC and Sunpro support aligned, packed and noreturn */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#define pg_attribute_noreturn() __attribute__((noreturn))
#define pg_attribute_packed() __attribute__((packed))
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
new file mode 100644
index 0000000000..1c2d166791
--- /dev/null
+++ b/src/include/port/aix.h
@@ -0,0 +1,6 @@
+/*
+ * src/include/port/aix.h
+ */
+#define CLASS_CONFLICT
+#define DISABLE_XOPEN_NLS
+
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 29ac6cdcd9..2f6eb5df2a 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -424,17 +424,15 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
-" bne 1f \n"
+" bne $+16 \n" /* branch to li %1,1 */
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
-" beq 2f \n"
-"1: \n"
+" beq $+12 \n" /* branch to lwsync */
" li %1,1 \n"
-" b 3f \n"
-"2: \n"
+" b $+12 \n" /* branch to end of asm sequence */
" lwsync \n"
" li %1,0 \n"
-"3: \n"
+
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
@@ -662,6 +660,21 @@ tas(volatile slock_t *lock)
#if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
+#if defined(_AIX) /* AIX */
+/*
+ * AIX (POWER)
+ */
+#define HAS_TEST_AND_SET
+
+#include <sys/atomic_op.h>
+
+typedef int slock_t;
+
+#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
+#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
+#endif /* _AIX */
+
+
/* These are in sunstudio_(sparc|x86).s */
#if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index b36a765764..154429d4d1 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -114,7 +114,7 @@ backend_src = $(top_srcdir)/src/backend
# coding rule.
libpq-refs-stamp: $(shlib)
ifneq ($(enable_coverage), yes)
-ifeq (,$(filter solaris,$(PORTNAME)))
+ifeq (,$(filter aix solaris,$(PORTNAME)))
@if nm -A -u $< 2>/dev/null | grep -v -e __cxa_atexit -e __tsan_func_exit | grep exit; then \
echo 'libpq must not be calling any function which invokes exit'; exit 1; \
fi
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index ed2a4048d1..7e2017daf0 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -54,8 +54,9 @@ libpq_c_args = ['-DSO_MAJOR_VERSION=5']
# libpq_st, and {pgport,common}_shlib for libpq_sh
#
# We could try to avoid building the source files twice, but it probably adds
-# more complexity than its worth (reusing object files requires also linking
-# to the library on windows or breaks precompiled headers).
+# more complexity than its worth (AIX doesn't support link_whole yet, reusing
+# object files requires also linking to the library on windows or breaks
+# precompiled headers).
libpq_st = static_library('libpq',
libpq_sources,
include_directories: [libpq_inc],
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
new file mode 100644
index 0000000000..dd16a7a037
--- /dev/null
+++ b/src/makefiles/Makefile.aix
@@ -0,0 +1,39 @@
+# MAKE_EXPORTS is required for svr4 loaders that want a file of
+# symbol names to tell them what to export/import.
+MAKE_EXPORTS= true
+
+# -blibpath must contain ALL directories where we should look for libraries
+libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/usr/lib:/lib
+
+# when building with gcc, need to make sure that libgcc can be found
+ifeq ($(GCC), yes)
+libpath := $(libpath):$(dir $(shell gcc -print-libgcc-file-name))
+endif
+
+rpath = -Wl,-blibpath:'$(rpathdir)$(libpath)'
+
+LDFLAGS_SL += -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE
+
+# gcc needs to know it's building a shared lib, otherwise it'll not emit
+# correct code / link to the right support libraries
+ifeq ($(GCC), yes)
+LDFLAGS_SL += -shared
+endif
+
+# env var name to use in place of LD_LIBRARY_PATH
+ld_library_path_var = LIBPATH
+
+
+POSTGRES_IMP= postgres.imp
+
+ifdef PGXS
+BE_DLLLIBS= -Wl,-bI:$(pkglibdir)/$(POSTGRES_IMP)
+else
+BE_DLLLIBS= -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP)
+endif
+
+MKLDEXPORT_DIR=src/backend/port/aix
+MKLDEXPORT=$(top_srcdir)/$(MKLDEXPORT_DIR)/mkldexport.sh
+
+%$(DLSUFFIX): %.o
+ $(CC) $(CFLAGS) $*.o $(LDFLAGS) $(LDFLAGS_SL) -o $@ $(BE_DLLLIBS)
diff --git a/src/port/README b/src/port/README
index ed5c54a72f..97f18a6233 100644
--- a/src/port/README
+++ b/src/port/README
@@ -28,5 +28,5 @@ applications.
from libpgport are linked first. This avoids having applications
dependent on symbols that are _used_ by libpq, but not intended to be
exported by libpq. libpq's libpgport usage changes over time, so such a
-dependency is a problem. Windows, Linux, and macOS use an export
+dependency is a problem. Windows, Linux, AIX, and macOS use an export
list to control the symbols exported by libpq.
diff --git a/src/port/strerror.c b/src/port/strerror.c
index 4918ba821c..1070a49802 100644
--- a/src/port/strerror.c
+++ b/src/port/strerror.c
@@ -214,8 +214,10 @@ get_errno_symbol(int errnum)
return "ENOTCONN";
case ENOTDIR:
return "ENOTDIR";
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
case ENOTEMPTY:
return "ENOTEMPTY";
+#endif
case ENOTSOCK:
return "ENOTSOCK";
#ifdef ENOTSUP
diff --git a/src/template/aix b/src/template/aix
new file mode 100644
index 0000000000..0a788676c0
--- /dev/null
+++ b/src/template/aix
@@ -0,0 +1,14 @@
+# src/template/aix
+
+ # Due to a compiler bug, see [email protected] for details,
+ # force restrict not to be used when compiling with xlc.
+# FORCE_DISABLE_RESTRICT=yes
+#fi
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
+# Native memset() is faster, tested on:
+# AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
+# AIX 5.3 ML3, gcc 4.0.1
+MEMSET_LOOP_LIMIT=0
diff --git a/src/test/regress/Makefile b/src/test/regress/Makefile
index 6409a485e8..7c665ff892 100644
--- a/src/test/regress/Makefile
+++ b/src/test/regress/Makefile
@@ -7,6 +7,11 @@
# GNU make uses a make file named "GNUmakefile" in preference to "Makefile"
# if it exists. Postgres is shipped with a "GNUmakefile".
+
+# AIX make defaults to building *every* target of the first rule. Start with
+# a single-target, empty rule to make the other targets non-default.
+all:
+
all install clean check installcheck:
@echo "You must use GNU make to use Postgres. It may be installed"
@echo "on your system with the name 'gmake'."
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index 8370c1561c..c5c675b750 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -25,3 +25,32 @@ SELECT relname, relkind
---------+---------
(0 rows)
+--
+-- When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on
+-- some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure
+-- catalog C struct layout matches catalog tuple layout, arrange for the tuple
+-- offset of each fixed-width, attalign='d' catalog column to be divisible by 8
+-- unconditionally. Keep such columns before the first NameData column of the
+-- catalog, since packagers can override NAMEDATALEN to an odd number.
+--
+WITH check_columns AS (
+ SELECT relname, attname,
+ array(
+ SELECT t.oid
+ FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
+ WHERE pa.attrelid = a.attrelid AND
+ pa.attnum > 0 AND pa.attnum < a.attnum
+ ORDER BY pa.attnum) AS coltypes
+ FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
+ JOIN pg_namespace n ON c.relnamespace = n.oid
+ WHERE attalign = 'd' AND relkind = 'r' AND
+ attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
+)
+SELECT relname, attname, coltypes, get_columns_length(coltypes)
+ FROM check_columns
+ WHERE get_columns_length(coltypes) % 8 != 0 OR
+ 'name'::regtype::oid = ANY(coltypes);
+ relname | attname | coltypes | get_columns_length
+---------+---------+----------+--------------------
+(0 rows)
+
diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out
index 3d0eeec996..5d9e6bf12b 100644
--- a/src/test/regress/expected/test_setup.out
+++ b/src/test/regress/expected/test_setup.out
@@ -209,6 +209,10 @@ CREATE FUNCTION ttdummy ()
RETURNS trigger
AS :'regresslib'
LANGUAGE C;
+CREATE FUNCTION get_columns_length(oid[])
+ RETURNS int
+ AS :'regresslib'
+ LANGUAGE C STRICT STABLE PARALLEL SAFE;
-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines. The hash function for int4 simply returns
-- the sum of the values passed to it and the one for text returns the length
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index deffaea578..cc633864d7 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -1221,3 +1221,43 @@ binary_coercible(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
}
+
+/*
+ * Return the length of the portion of a tuple consisting of the given array
+ * of data types. The input data types must be fixed-length data types.
+ */
+PG_FUNCTION_INFO_V1(get_columns_length);
+Datum
+get_columns_length(PG_FUNCTION_ARGS)
+{
+ ArrayType *ta = PG_GETARG_ARRAYTYPE_P(0);
+ Oid *type_oids;
+ int ntypes;
+ int column_offset = 0;
+
+ if (ARR_HASNULL(ta) && array_contains_nulls(ta))
+ elog(ERROR, "argument must not contain nulls");
+
+ if (ARR_NDIM(ta) > 1)
+ elog(ERROR, "argument must be empty or one-dimensional array");
+
+ type_oids = (Oid *) ARR_DATA_PTR(ta);
+ ntypes = ArrayGetNItems(ARR_NDIM(ta), ARR_DIMS(ta));
+ for (int i = 0; i < ntypes; i++)
+ {
+ Oid typeoid = type_oids[i];
+ int16 typlen;
+ bool typbyval;
+ char typalign;
+
+ get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign);
+
+ /* the data type must be fixed-length */
+ if (typlen < 0)
+ elog(ERROR, "type %u is not fixed-length data type", typeoid);
+
+ column_offset = att_align_nominal(column_offset + typlen, typalign);
+ }
+
+ PG_RETURN_INT32(column_offset);
+}
diff --git a/src/test/regress/sql/sanity_check.sql b/src/test/regress/sql/sanity_check.sql
index 162e5324b5..7f338d191c 100644
--- a/src/test/regress/sql/sanity_check.sql
+++ b/src/test/regress/sql/sanity_check.sql
@@ -19,3 +19,29 @@ SELECT relname, relkind
FROM pg_class
WHERE relkind IN ('v', 'c', 'f', 'p', 'I')
AND relfilenode <> 0;
+
+--
+-- When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on
+-- some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure
+-- catalog C struct layout matches catalog tuple layout, arrange for the tuple
+-- offset of each fixed-width, attalign='d' catalog column to be divisible by 8
+-- unconditionally. Keep such columns before the first NameData column of the
+-- catalog, since packagers can override NAMEDATALEN to an odd number.
+--
+WITH check_columns AS (
+ SELECT relname, attname,
+ array(
+ SELECT t.oid
+ FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
+ WHERE pa.attrelid = a.attrelid AND
+ pa.attnum > 0 AND pa.attnum < a.attnum
+ ORDER BY pa.attnum) AS coltypes
+ FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
+ JOIN pg_namespace n ON c.relnamespace = n.oid
+ WHERE attalign = 'd' AND relkind = 'r' AND
+ attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
+)
+SELECT relname, attname, coltypes, get_columns_length(coltypes)
+ FROM check_columns
+ WHERE get_columns_length(coltypes) % 8 != 0 OR
+ 'name'::regtype::oid = ANY(coltypes);
diff --git a/src/test/regress/sql/test_setup.sql b/src/test/regress/sql/test_setup.sql
index 06b0e2121f..1b2d434683 100644
--- a/src/test/regress/sql/test_setup.sql
+++ b/src/test/regress/sql/test_setup.sql
@@ -257,6 +257,11 @@ CREATE FUNCTION ttdummy ()
AS :'regresslib'
LANGUAGE C;
+CREATE FUNCTION get_columns_length(oid[])
+ RETURNS int
+ AS :'regresslib'
+ LANGUAGE C STRICT STABLE PARALLEL SAFE;
+
-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines. The hash function for int4 simply returns
-- the sum of the values passed to it and the one for text returns the length
diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl
index d9fdaaaf6d..888c8a197a 100644
--- a/src/tools/gen_export.pl
+++ b/src/tools/gen_export.pl
@@ -16,11 +16,12 @@ GetOptions(
'input:s' => \$input,
'output:s' => \$output) or die "wrong arguments";
-if (not( $format eq 'darwin'
+if (not( $format eq 'aix'
+ or $format eq 'darwin'
or $format eq 'gnu'
or $format eq 'win'))
{
- die "$0: $format is not yet handled (only darwin, gnu, win are)\n";
+ die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n";
}
open(my $input_handle, '<', $input)
@@ -55,7 +56,11 @@ while (<$input_handle>)
}
elsif (/^(\S+)\s+(\S+)/)
{
- if ($format eq 'darwin')
+ if ($format eq 'aix')
+ {
+ print $output_handle "$1\n";
+ }
+ elsif ($format eq 'darwin')
{
print $output_handle "_$1\n";
}
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 4a157d0a5f..cfd8c6896c 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -85,6 +85,7 @@ do
# These files are platform-specific, and c.h will include the
# one that's relevant for our current platform anyway.
+ test "$f" = src/include/port/aix.h && continue
test "$f" = src/include/port/cygwin.h && continue
test "$f" = src/include/port/darwin.h && continue
test "$f" = src/include/port/freebsd.h && continue
--
2.41.0
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-08-14 20:09 ` Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Heikki Linnakangas @ 2024-08-14 20:09 UTC (permalink / raw)
To: Srirama Kucherlapati <[email protected]>; Heikki Linnakangas <[email protected]>; Laurenz Albe <[email protected]>; Bruce Momjian <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Tom Lane <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
On 14/08/2024 18:22, Srirama Kucherlapati wrote:
> Hi Heikki,
>
> I have attached the merged patch with all the changes, the earlier patch was
>
> just only the changes specific to older review comments.
>
> > I'm sorry, I don't understand what you're saying here. Do you
> mean that
> > we don't need to do anything here, and the code we have in
> s_lock.h in
> > 'master' now will work fine on AIX? Or do we need to (re-)do some
> > changes to support AIX again? If we only support GCC, can we use the
> > __sync_lock_test_and_set() builtin instead?
>
> Here we need these changes for ppc. These changes are not for
> enabling the AIX support, but this is implementing “Enhanced PowerPC
> Architecture”. This routine is more of compare_and_increment, which
> is different from GCC __sync_lock_test_and_set(). Also I tried to
> write a sample function to check the assemble generated by
> __sync_lock_test_and_set(), which turned out to be different set of
> assemble code.
I still don't understand. We have Linux powerpc systems running happily
in the buildfarm. They are happy with the current spinlock
implementation. Why is this needed? What happens without it?
How is this different from __sync_lock_test_and_set()? Is the
__sync_lock_test_and_set() on that platform broken, less efficient, or
just different but equally good?
> > > +#define TAS(lock) _check_lock((slock_t *)
> (lock),
> > > 0, 1)
> > >
> >> +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
> >>
> > > The above changes are specific to AIX kernel and it operates on
> fixed
> > > kernel memory. This is more like a compare_and_swap
> functionality with
> > > sync capability. For all the assemble code I think it would be
> better to
> > > use the IBM Power specific asm code to gain additional performance.
>
> > You mean we don't need the above? Ok, good.
>
> I mean this part of the code is needed as this is specific to AIX
> kernel memory operation which is different from
> __sync_lock_test_and_set().
How is it different from __sync_lock_test_and_set()? Why is it needed?
What is AIX kernel memory operation?
> I would like to mention that the changes made in
> src/include/storage/s_lock.h
>
> are pretty much required and need to be operated in assemble specific to IBM
> Power architecture.
Note that your patch both modifies the existing powerpc implementation,
and introduces a new AIX-specific one. They cannot *both* be required,
because only one of them will ever be compiled on a given platform.
Which is it? Or are you trying to make this work on multiple different
CPUs on AIX, so that different implementation gets chosen on different CPUs?
Is the mkldexport stuff still needed on modern AIX? Or was it specific
to XLC and never needed on GCC? How do other products do that?
On a general note: it's your responsibility to explain all the changes
in a way that others will understand and can verify. It is especially
important for something critical and platform-specific like spinlocks,
because others don't have easy access to the hardware to test these
things independently. I also want to remind you that from the Postgres
community point of view, you are introducing support for a new platform,
AIX, not merely resurrecting the old stuff. Every change needs to be
justified anew.
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
@ 2024-09-11 12:38 ` Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-09-11 12:38 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
Hi Heikki and Team,
Thanks for your comments.
Here are some more details
> I still don't understand. We have Linux powerpc systems
> running happily in the buildfarm. They are happy with the
> current spinlock implementation. Why is this needed?
> What happens without it?
Not sure, by the time the below commits were made if there was a consideration
to use the gcc routines. My guess is that by using this PPC assembler code
would make the code independent of the compilers. Even the Linux ppc would use the
same asm. Since gcc is available on AIX, I have replaced the asm changes with
the gcc routine __sync_lock_test_and_set() to set the lock.
We have the gcc(package) build on the AIX platform and as part of the testsuite
there are no issues wrt this routine. We tried to test with the sample test
program extracted from gcc testsuite. Also we discussed the same with our
compiler teams internally and they see no issues using this routine.
<attached sample test> gcc-12.4.0/libgomp/testsuite/libgomp.c/sections-1.c
--------
> > +#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
> >
> > +#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
> >
> How is it different from __sync_lock_test_and_set()? Why is it needed?
> What is AIX kernel memory operation?
More Info: _check_lock routine description
https://www.ibm.com/docs/en/aix/7.1?topic=c-check-lock-subroutine
The _check_lock subroutine performs an atomic (uninterruptible) sequence of
operations. The compare_and_swap subroutine is similar, but does not issue
synchronization instructions and therefore is inappropriate for updating lock
words.
This change need not be replaced with gcc routine as, these changes will be
compiled for the non-gcc platforms only. This piece of code would never be
compiled, as we are using only gcc to build.
I tried to replace the AIX asm (under__ppc__ macro) with the gcc routine
__sync_lock_test_and_set(), and all the buildfarm tests passed. Attached patch
and the buildfarm output. Please let me know your feedback.
----
> On a general note: it's your responsibility to explain all the changes
> in a way that others will understand and can verify. It is especially
> important for something critical and platform-specific like spinlocks,
> because others don't have easy access to the hardware to test these
> things independently. I also want to remind you that from the Postgres
> community point of view, you are introducing support for a new platform,
> AIX, not merely resurrecting the old stuff. Every change needs to be
> justified anew.
I do agree with you. To have a better understand on the previous changes,
I was going through the history of the file(s_lock.h) and see that multiple
changes that were made wrt the tas()routine specific to ppc/AIX. Below are
the commit levels.
I would kindly request, Tom Lane, to provide some insights on these changes.
commit e3b06a871b63b90d4a08560ce184bb33324410b8
commit 50938576d482cd36e52a60b5bb1b56026e63962a << added tas() for AIX
commit 7233aae50bea503369b0a4ef9a3b6a3864c96812
commit ceb4f5ea9c2c6c2bd44d4799ff4a62c40a038894 << added tas() for PPC
commit f9ba0a7fe56398e89fe349476d9e437c3197ea28
commit eb5e4c58d137c9258eff5e41b09cb5fe4ed6d64c
commit cd35d601b859d3a56632696b8d5293cbe547764b
commit 109867748259d286dd01fce17d5f895ce59c68d5
commit 5cfa8dd3007d7e953c6a03b0fa2215d97c581b0c
commit 631beeac3598a73dee2c2afa38fa2e734148031b
commit bc2a050d40976441cdb963ad829316c23e8df0aa
commit c41a1215f04912108068b909569551f42059db29
commit 50938576d482cd36e52a60b5bb1b56026e63962a
Please let me know if would like to try on the hardware, we have recently
setup a node in the OSU lab to try out.
Thanks,
Sriram.
/* Test that all sections are touched. */
/* { dg-require-effective-target sync_int_long } */
#include <omp.h>
#include <string.h>
#include <assert.h>
#include "libgomp_g.h"
#define N 100
static int data[N];
static int NTHR;
static void clean_data (void)
{
memset (data, -1, sizeof (data));
}
static void test_data (void)
{
int i;
for (i = 0; i < N; ++i)
assert (data[i] != -1);
}
static void set_data (unsigned i, int val)
{
int old;
assert (i >= 1 && i <= N);
old = __sync_lock_test_and_set (data+i-1, val);
assert (old == -1);
}
static void f_1 (void *dummy)
{
int iam = omp_get_thread_num ();
unsigned long s;
for (s = GOMP_sections_start (N); s ; s = GOMP_sections_next ())
set_data (s, iam);
GOMP_sections_end ();
}
static void test_1 (void)
{
clean_data ();
GOMP_parallel_start (f_1, NULL, NTHR);
f_1 (NULL);
GOMP_parallel_end ();
test_data ();
}
static void f_2 (void *dummy)
{
int iam = omp_get_thread_num ();
unsigned s;
while ((s = GOMP_sections_next ()))
set_data (s, iam);
GOMP_sections_end_nowait ();
}
static void test_2 (void)
{
clean_data ();
GOMP_parallel_sections_start (f_2, NULL, NTHR, N);
f_2 (NULL);
GOMP_parallel_end ();
test_data ();
}
int main()
{
omp_set_dynamic (0);
NTHR = 4;
test_1 ();
test_2 ();
return 0;
}
Attachments:
[application/octet-stream] 0001-AIX-support-revert-the-changes-from-0b16bb8776bb8.v4.patch (44.9K, 3-0001-AIX-support-revert-the-changes-from-0b16bb8776bb8.v4.patch)
download | inline diff:
From f162e7d01f34957c906f96cde865937e05f15038 Mon Sep 17 00:00:00 2001
From: Sriram RK <[email protected]>
Date: Mon, 20 May 2024 01:38:59 -0500
Subject: [PATCH 1/1] AIX support, revert the changes from 0b16bb8776bb8. Trim
AIX/XLC changes to support gcc only.
- Review comments from Heikki.
- Replace tas() AIX asm with gcc __sync_lock_test_and_set().
- Fix tas() for powerPC.
---
Makefile | 2 -
configure | 37 +++---
configure.ac | 28 ++---
doc/src/sgml/dfunc.sgml | 19 +++
doc/src/sgml/installation.sgml | 118 +++++++++++++++++-
doc/src/sgml/runtime.sgml | 23 ++++
meson.build | 57 +++++----
src/Makefile.shlib | 29 +++++
src/backend/Makefile | 20 +++
src/backend/meson.build | 15 +++
src/backend/port/aix/mkldexport.sh | 61 +++++++++
src/backend/utils/error/elog.c | 2 +
src/backend/utils/misc/ps_status.c | 4 +-
src/bin/pg_basebackup/t/010_pg_basebackup.pl | 3 +-
src/bin/pg_verifybackup/t/008_untar.pl | 3 +-
src/bin/pg_verifybackup/t/010_client_untar.pl | 3 +-
src/include/c.h | 4 +-
src/include/port/aix.h | 6 +
src/include/storage/s_lock.h | 62 +++------
src/interfaces/libpq/Makefile | 2 +-
src/interfaces/libpq/meson.build | 5 +-
src/makefiles/Makefile.aix | 39 ++++++
src/port/README | 2 +-
src/port/strerror.c | 2 +
src/template/aix | 14 +++
src/test/regress/Makefile | 5 +
src/test/regress/expected/sanity_check.out | 29 +++++
src/test/regress/expected/test_setup.out | 4 +
src/test/regress/regress.c | 40 ++++++
src/test/regress/sql/sanity_check.sql | 26 ++++
src/test/regress/sql/test_setup.sql | 5 +
src/tools/gen_export.pl | 11 +-
src/tools/pginclude/headerscheck | 1 +
33 files changed, 554 insertions(+), 127 deletions(-)
create mode 100755 src/backend/port/aix/mkldexport.sh
create mode 100644 src/include/port/aix.h
create mode 100644 src/makefiles/Makefile.aix
create mode 100644 src/template/aix
diff --git a/Makefile b/Makefile
index 8a2ec9396b..9bc1a4ec17 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,6 @@
# AIX make defaults to building *every* target of the first rule. Start with
# a single-target, empty rule to make the other targets non-default.
-# (We don't support AIX anymore, but if someone tries to build on AIX anyway,
-# at least they'll get the instructions to run 'configure' first.)
all:
all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world check-world install-world installcheck-world:
diff --git a/configure b/configure
index 89644f2249..f218b2e040 100755
--- a/configure
+++ b/configure
@@ -2988,6 +2988,7 @@ else
# --with-template not given
case $host_os in
+ aix*) template=aix ;;
cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
@@ -6848,7 +6849,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fno_strict_aliasing" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
fi
-
fi
# If the compiler knows how to hide symbols, add the switch needed for that to
@@ -12860,7 +12860,8 @@ fi
fi
-# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS;
+# also, on AIX, we may need to have openssl in LIBS for this step.
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
@@ -16951,28 +16952,18 @@ _ACEOF
# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that long's alignment is at least as strong as
-# char, short, or int. Note that we intentionally do not consider any types
-# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too
-# much of a penalty for disk and memory space.
-
-MAX_ALIGNOF=$ac_cv_alignof_double
+# We assume long's alignment is at least as strong as char, short, or int;
+# but we must check long long (if it is being used for int64) and double.
+# Note that we intentionally do not consider any types wider than 64 bits,
+# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
+# for disk and memory space.
-if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long' is greater than the alignment of 'double'" "$LINENO" 5
+MAX_ALIGNOF=$ac_cv_alignof_long
+if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
+ MAX_ALIGNOF=$ac_cv_alignof_double
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long long int' is greater than the alignment of 'double'" "$LINENO" 5
+if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ; then
+ MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
fi
cat >>confdefs.h <<_ACEOF
@@ -17090,7 +17081,7 @@ else
/* end confdefs.h. */
/* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/configure.ac b/configure.ac
index c7322e292c..a059509cd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ PGAC_ARG_REQ(with, template, [NAME], [override operating system template],
# --with-template not given
case $host_os in
+ aix*) template=aix ;;
cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
@@ -1385,7 +1386,8 @@ if test "$with_zstd" = yes ; then
AC_CHECK_LIB(zstd, ZSTD_compress, [], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])])
fi
-# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS;
+# also, on AIX, we may need to have openssl in LIBS for this step.
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
@@ -1643,8 +1645,9 @@ PGAC_TYPE_LOCALE_T
# spelling it understands, because it conflicts with
# __declspec(restrict). Therefore we define pg_restrict to the
# appropriate definition, which presumably won't conflict.
+#
AC_C_RESTRICT
-if test "$ac_cv_c_restrict" = "no"; then
+if test "$ac_cv_c_restrict" = "no" ; then
pg_restrict=""
else
pg_restrict="$ac_cv_c_restrict"
@@ -1996,22 +1999,11 @@ fi
AC_CHECK_ALIGNOF(double)
# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that long's alignment is at least as strong as
-# char, short, or int. Note that we intentionally do not consider any types
-# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too
-# much of a penalty for disk and memory space.
-
-MAX_ALIGNOF=$ac_cv_alignof_double
+# We assume long's alignment is at least as strong as char, short, or int;
+# but we must check long long (if it is being used for int64) and double.
+# Note that we intentionally do not consider any types wider than 64 bits,
+# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
+# for disk and memory space.
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
AC_MSG_ERROR([alignment of 'long' is greater than the alignment of 'double'])
diff --git a/doc/src/sgml/dfunc.sgml b/doc/src/sgml/dfunc.sgml
index b94aefcd0c..554f9fac4c 100644
--- a/doc/src/sgml/dfunc.sgml
+++ b/doc/src/sgml/dfunc.sgml
@@ -202,4 +202,23 @@ gcc -G -o foo.so foo.o
server expects to find the shared library files.
</para>
+<!--
+Under AIX, object files are compiled normally but building the shared
+library requires a couple of steps. First, create the object file:
+.nf
+cc <other flags> -c foo.c
+.fi
+You must then create a symbol \*(lqexports\*(rq file for the object
+file:
+.nf
+mkldexport foo.o `pwd` > foo.exp
+.fi
+Finally, you can create the shared library:
+.nf
+ld <other flags> -H512 -T512 -o foo.so -e _nostart \e
+ -bI:.../lib/postgres.exp -bE:foo.exp foo.o \e
+ -lm -lc 2>/dev/null
+.fi
+ -->
+
</sect2>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1b32d5ca62..60e9a34a03 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -3401,7 +3401,7 @@ export MANPATH
<para>
<productname>PostgreSQL</productname> can be expected to work on current
versions of these operating systems: Linux, Windows,
- FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, Solaris, and illumos.
+ FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, AIX, Solaris, and illumos.
Other Unix-like systems may also work but are not currently
being tested. In most cases, all CPU architectures supported by
a given operating system will work. Look in
@@ -3445,6 +3445,122 @@ export MANPATH
installation issues.
</para>
+ <sect2 id="installation-notes-aix">
+ <title>AIX</title>
+
+ <indexterm zone="installation-notes-aix">
+ <primary>AIX</primary>
+ <secondary>installation on</secondary>
+ </indexterm>
+
+ <para>
+ You can use GCC to build <productname>PostgreSQL</productname>
+ on <productname>AIX</productname>.
+ </para>
+
+ <para>
+ <productname>AIX</productname> versions before 7.1 are no longer
+ tested nor supported by the <productname>PostgreSQL</productname>
+ community.
+ </para>
+
+ <sect3 id="installation-notes-aix-mem-management">
+ <title>Memory Management</title>
+ <!-- https://archives.postgresql.org/message-id/[email protected] -->
+
+ <para>
+ AIX can be somewhat peculiar with regards to the way it does
+ memory management. You can have a server with many multiples of
+ gigabytes of RAM free, but still get out of memory or address
+ space errors when running applications. One example
+ is loading of extensions failing with unusual errors.
+ For example, running as the owner of the PostgreSQL installation:
+<screen>
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process.
+</screen>
+ Running as a non-owner in the group possessing the PostgreSQL
+ installation:
+<screen>
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
+</screen>
+ Another example is out of memory errors in the PostgreSQL server
+ logs, with every memory allocation near or greater than 256 MB
+ failing.
+ </para>
+
+ <para>
+ The overall cause of all these problems is the default bittedness
+ and memory model used by the server process. By default, all
+ binaries built on AIX are 32-bit. This does not depend upon
+ hardware type or kernel in use. These 32-bit processes are
+ limited to 4 GB of memory laid out in 256 MB segments using one
+ of a few models. The default allows for less than 256 MB in the
+ heap as it shares a single segment with the stack.
+ </para>
+
+ <para>
+ In the case of the <literal>plperl</literal> example, above,
+ check your umask and the permissions of the binaries in your
+ PostgreSQL installation. The binaries involved in that example
+ were 32-bit and installed as mode 750 instead of 755. Due to the
+ permissions being set in this fashion, only the owner or a member
+ of the possessing group can load the library. Since it isn't
+ world-readable, the loader places the object into the process'
+ heap instead of the shared library segments where it would
+ otherwise be placed.
+ </para>
+
+ <para>
+ The <quote>ideal</quote> solution for this is to use a 64-bit
+ build of PostgreSQL, but that is not always practical, because
+ systems with 32-bit processors can build, but not run, 64-bit
+ binaries.
+ </para>
+
+ <para>
+ If a 32-bit binary is desired, set <symbol>LDR_CNTRL</symbol> to
+ <literal>MAXDATA=0x<replaceable>n</replaceable>0000000</literal>,
+ where 1 <= n <= 8, before starting the PostgreSQL server,
+ and try different values and <filename>postgresql.conf</filename>
+ settings to find a configuration that works satisfactorily. This
+ use of <symbol>LDR_CNTRL</symbol> tells AIX that you want the
+ server to have <symbol>MAXDATA</symbol> bytes set aside for the
+ heap, allocated in 256 MB segments. When you find a workable
+ configuration,
+ <command>ldedit</command> can be used to modify the binaries so
+ that they default to using the desired heap size. PostgreSQL can
+ also be rebuilt, passing <literal>configure
+ LDFLAGS="-Wl,-bmaxdata:0x<replaceable>n</replaceable>0000000"</literal>
+ to achieve the same effect.
+ </para>
+
+ <para>
+ For a 64-bit build, set <envar>OBJECT_MODE</envar> to 64 and
+ pass <literal>CC="gcc -maix64"</literal>
+ and <literal>LDFLAGS="-Wl,-bbigtoc"</literal>
+ to <command>configure</command>.
+ If you omit the export of
+ <envar>OBJECT_MODE</envar>, your build may fail with linker errors. When
+ <envar>OBJECT_MODE</envar> is set, it tells AIX's build utilities
+ such as <command>ar</command>, <command>as</command>, and <command>ld</command> what
+ type of objects to default to handling.
+ </para>
+
+ <para>
+ By default, overcommit of paging space can happen. While we have
+ not seen this occur, AIX will kill processes when it runs out of
+ memory and the overcommit is accessed. The closest to this that
+ we have seen is fork failing because the system decided that
+ there was not enough memory for another process. Like many other
+ parts of AIX, the paging space allocation method and
+ out-of-memory kill is configurable on a system- or process-wide
+ basis if this becomes a problem.
+ </para>
+ </sect3>
+ </sect2>
+
<sect2 id="installation-notes-cygwin">
<title>Cygwin</title>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 6047b8171d..64753d9c01 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -891,6 +891,29 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
<variablelist>
+ <varlistentry>
+ <term><systemitem class="osname">AIX</systemitem>
+ <indexterm><primary>AIX</primary><secondary>IPC configuration</secondary></indexterm>
+ </term>
+ <listitem>
+ <para>
+ It should not be necessary to do
+ any special configuration for such parameters as
+ <varname>SHMMAX</varname>, as it appears this is configured to
+ allow all memory to be used as shared memory. That is the
+ sort of configuration commonly used for other databases such
+ as <application>DB/2</application>.</para>
+
+ <para> It might, however, be necessary to modify the global
+ <command>ulimit</command> information in
+ <filename>/etc/security/limits</filename>, as the default hard
+ limits for file sizes (<varname>fsize</varname>) and numbers of
+ files (<varname>nofiles</varname>) might be too low.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
<varlistentry>
<term><systemitem class="osname">FreeBSD</systemitem>
<indexterm><primary>FreeBSD</primary><secondary>IPC configuration</secondary></indexterm>
diff --git a/meson.build b/meson.build
index 1c0579d5a6..f1ac154cdc 100644
--- a/meson.build
+++ b/meson.build
@@ -196,7 +196,26 @@ endif
# that purpose.
portname = host_system
-if host_system == 'cygwin'
+if host_system == 'aix'
+ library_path_var = 'LIBPATH'
+
+ export_file_format = 'aix'
+ export_fmt = '-Wl,-bE:@0@'
+ mod_link_args_fmt = ['-Wl,-bI:@0@']
+ mod_link_with_dir = 'libdir'
+ mod_link_with_name = '@[email protected]'
+
+ # M:SRE sets a flag indicating that an object is a shared library. Seems to
+ # work in some circumstances without, but required in others.
+ ldflags_sl += '-Wl,-bM:SRE'
+ ldflags_be += '-Wl,-brtllib'
+
+ # Native memset() is faster, tested on:
+ # - AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
+ # - AIX 5.3 ML3, gcc 4.0.1
+ memset_loop_limit = 0
+
+elif host_system == 'cygwin'
sema_kind = 'unnamed_posix'
cppflags += '-D_GNU_SOURCE'
dlsuffix = '.dll'
@@ -1490,11 +1509,11 @@ sizeof_long = cc.sizeof('long', args: test_c_args)
cdata.set('SIZEOF_LONG', sizeof_long)
if sizeof_long == 8
cdata.set('HAVE_LONG_INT_64', 1)
- pg_int64_type = 'long int'
+ cdata.set('PG_INT64_TYPE', 'long int')
cdata.set_quoted('INT64_MODIFIER', 'l')
elif sizeof_long == 4 and cc.sizeof('long long', args: test_c_args) == 8
cdata.set('HAVE_LONG_LONG_INT_64', 1)
- pg_int64_type = 'long long int'
+ cdata.set('PG_INT64_TYPE', 'long long int')
cdata.set_quoted('INT64_MODIFIER', 'll')
else
error('do not know how to get a 64bit int')
@@ -1508,31 +1527,15 @@ endif
# Determine memory alignment requirements for the basic C data types.
alignof_types = ['short', 'int', 'long', 'double']
+maxalign = 0
foreach t : alignof_types
align = cc.alignment(t, args: test_c_args)
+ if maxalign < align
+ maxalign = align
+ endif
cdata.set('ALIGNOF_@0@'.format(t.to_upper()), align)
endforeach
-
-# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that int64's alignment is at least as strong
-# as long, char, short, or int. Note that we intentionally do not consider
-# any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8
-# would be too much of a penalty for disk and memory space.
-alignof_double = cdata.get('ALIGNOF_DOUBLE')
-if cc.alignment(pg_int64_type, args: test_c_args) > alignof_double
- error('alignment of int64 is greater than the alignment of double')
-endif
-cdata.set('MAXIMUM_ALIGNOF', alignof_double)
+cdata.set('MAXIMUM_ALIGNOF', maxalign)
cdata.set('SIZEOF_VOID_P', cc.sizeof('void *', args: test_c_args))
cdata.set('SIZEOF_SIZE_T', cc.sizeof('size_t', args: test_c_args))
@@ -1581,7 +1584,7 @@ if cc.links('''
if not meson.is_cross_build()
r = cc.run('''
/* This must match the corresponding code in c.h: */
- #if defined(__GNUC__) || defined(__SUNPRO_C)
+ #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
@@ -2476,6 +2479,10 @@ endif
# conflict.
#
# We assume C99 support, so we don't need to make this conditional.
+#
+# XXX: Historically we allowed platforms to disable restrict in template
+# files, but that was only added for AIX when building with XLC, which we
+# don't support yet.
cdata.set('pg_restrict', '__restrict')
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index fa81f6ffdd..8ca51ca03f 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -106,6 +106,20 @@ ifdef SO_MAJOR_VERSION
override CPPFLAGS += -DSO_MAJOR_VERSION=$(SO_MAJOR_VERSION)
endif
+ifeq ($(PORTNAME), aix)
+ LINK.shared = $(COMPILER)
+ ifdef SO_MAJOR_VERSION
+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ endif
+ haslibarule = yes
+ # $(exports_file) is also usable as an import file
+ exports_file = lib$(NAME).exp
+ BUILD.exports = ( echo '\#! $(shlib)'; $(AWK) '/^[^\#]/ {printf "%s\n",$$1}' $< ) > $@
+ ifneq (,$(SHLIB_EXPORTS))
+ LINK.shared += -Wl,-bE:$(exports_file)
+ endif
+endif
+
ifeq ($(PORTNAME), darwin)
ifdef soname
# linkable library
@@ -254,6 +268,14 @@ $(stlib): $(OBJS) | $(SHLIB_PREREQS)
touch $@
endif #haslibarule
+# AIX wraps shared libraries inside a static library, can be used both
+# for static and shared linking
+ifeq ($(PORTNAME), aix)
+$(stlib): $(shlib)
+ rm -f $(stlib)
+ $(AR) $(AROPT) $(stlib) $(shlib)
+endif # aix
+
ifeq (,$(filter cygwin win32,$(PORTNAME)))
# Normal case
@@ -267,8 +289,11 @@ ifneq ($(shlib), $(shlib_major))
endif
# Make sure we have a link to a name without any version numbers
ifneq ($(shlib), $(shlib_bare))
+# except on AIX, where that's not a thing
+ifneq ($(PORTNAME), aix)
rm -f $(shlib_bare)
$(LN_S) $(shlib) $(shlib_bare)
+endif # aix
endif # shlib_bare
endif # shlib_major
@@ -376,6 +401,9 @@ install-lib-static: $(stlib) installdirs-lib
install-lib-shared: $(shlib) installdirs-lib
ifdef soname
+# we don't install $(shlib) on AIX
+# (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at)
+ifneq ($(PORTNAME), aix)
$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
@@ -391,6 +419,7 @@ ifneq ($(shlib), $(shlib_bare))
endif
endif # not win32
endif # not cygwin
+endif # not aix
ifneq (,$(findstring $(PORTNAME),win32 cygwin))
$(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
endif
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 6700aec039..954b14962f 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -62,12 +62,14 @@ all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
+ifneq ($(PORTNAME), aix)
postgres: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
endif
endif
+endif
ifeq ($(PORTNAME), cygwin)
@@ -94,6 +96,24 @@ libpostgres.a: postgres
endif # win32
+ifeq ($(PORTNAME), aix)
+
+postgres: $(POSTGRES_IMP)
+ $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
+
+# Linking to a single .o with -r is a lot faster than building a .a or passing
+# all objects to MKLDEXPORT.
+#
+# It looks alluring to use $(CC) -r instead of ld -r, but that doesn't
+# trivially work with gcc, due to gcc specific static libraries linked in with
+# -r.
+$(POSTGRES_IMP): $(OBJS)
+ ld -r -o SUBSYS.o $(call expand_subsys,$^)
+ $(MKLDEXPORT) SUBSYS.o . > $@
+ @rm -f SUBSYS.o
+
+endif # aix
+
$(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 436c04af08..8767aaba67 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -91,6 +91,21 @@ if cc.get_id() == 'msvc'
# be restricted to b_pch=true.
backend_link_with += postgres_lib
+elif host_system == 'aix'
+ # The '.' argument leads mkldexport.sh to emit "#! .", which refers to the
+ # main executable, allowing extension libraries to resolve their undefined
+ # symbols to symbols in the postgres binary.
+ postgres_imp = custom_target('postgres.imp',
+ command: [files('port/aix/mkldexport.sh'), '@INPUT@', '.'],
+ input: postgres_lib,
+ output: 'postgres.imp',
+ capture: true,
+ install: true,
+ install_dir: dir_lib,
+ build_by_default: false,
+ )
+ backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path())
+ backend_link_depends += postgres_imp
endif
backend_input = []
diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh
new file mode 100755
index 0000000000..adf3793e86
--- /dev/null
+++ b/src/backend/port/aix/mkldexport.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# mkldexport
+# create an AIX exports file from an object file
+#
+# src/backend/port/aix/mkldexport.sh
+#
+# Usage:
+# mkldexport objectfile [location]
+# where
+# objectfile is the current location of the object file.
+# location is the eventual (installed) location of the
+# object file (if different from the current
+# working directory).
+#
+# [This file comes from the Postgres 4.2 distribution. - ay 7/95]
+#
+# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp
+#
+
+# setting this to nm -B might be better
+# ... due to changes in AIX 4.x ...
+# ... let us search in different directories - Gerhard Reithofer
+if [ -x /usr/ucb/nm ]
+then NM=/usr/ucb/nm
+elif [ -x /usr/bin/nm ]
+then NM=/usr/bin/nm
+elif [ -x /usr/ccs/bin/nm ]
+then NM=/usr/ccs/bin/nm
+elif [ -x /usr/usg/bin/nm ]
+then NM=/usr/usg/bin/nm
+else echo "Fatal error: cannot find `nm' ... please check your installation."
+ exit 1
+fi
+
+CMDNAME=`basename $0`
+if [ -z "$1" ]; then
+ echo "Usage: $CMDNAME object [location]"
+ exit 1
+fi
+OBJNAME=`basename $1`
+if [ "`basename $OBJNAME`" != "`basename $OBJNAME .o`" ]; then
+ OBJNAME=`basename $OBJNAME .o`.so
+fi
+if [ -z "$2" ]; then
+ echo '#!'
+else
+ if [ "$2" = "." ]; then
+ # for the base executable (AIX 4.2 and up)
+ echo '#! .'
+ else
+ echo '#!' $2
+ fi
+fi
+$NM -BCg $1 | \
+ egrep ' [TDB] ' | \
+ sed -e 's/.* //' | \
+ egrep -v '\$' | \
+ sed -e 's/^[.]//' | \
+ sort | \
+ uniq
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index d91a85cb2d..7b51e94f4a 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -908,7 +908,9 @@ errcode_for_file_access(void)
/* Wrong object type or state */
case ENOTDIR: /* Not a directory */
case EISDIR: /* Is a directory */
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
case ENOTEMPTY: /* Directory not empty */
+#endif
edata->sqlerrcode = ERRCODE_WRONG_OBJECT_TYPE;
break;
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index 9da6377402..532eac31b4 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -50,7 +50,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
#define PS_USE_SETPROCTITLE_FAST
#elif defined(HAVE_SETPROCTITLE)
#define PS_USE_SETPROCTITLE
-#elif defined(__linux__) || defined(__sun) || defined(__darwin__)
+#elif defined(__linux__) || defined(_AIX) || defined(__sun) || defined(__darwin__)
#define PS_USE_CLOBBER_ARGV
#elif defined(WIN32)
#define PS_USE_WIN32
@@ -60,7 +60,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
/* Different systems want the buffer padded differently */
-#if defined(__linux__) || defined(__darwin__)
+#if defined(_AIX) || defined(__linux__) || defined(__darwin__)
#define PS_PADDING '\0'
#else
#define PS_PADDING ' '
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 2d4b75a6fe..ce936959c1 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -401,7 +401,8 @@ SKIP:
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/bin/pg_verifybackup/t/008_untar.pl b/src/bin/pg_verifybackup/t/008_untar.pl
index 7a09f3b75b..30d9f3f7f0 100644
--- a/src/bin/pg_verifybackup/t/008_untar.pl
+++ b/src/bin/pg_verifybackup/t/008_untar.pl
@@ -104,7 +104,8 @@ for my $tc (@test_configuration)
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/bin/pg_verifybackup/t/010_client_untar.pl b/src/bin/pg_verifybackup/t/010_client_untar.pl
index 8c076d46de..45010d79ac 100644
--- a/src/bin/pg_verifybackup/t/010_client_untar.pl
+++ b/src/bin/pg_verifybackup/t/010_client_untar.pl
@@ -134,7 +134,8 @@ for my $tc (@test_configuration)
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/include/c.h b/src/include/c.h
index dc1841346c..641cd9bdf1 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -182,7 +182,7 @@
#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
#endif
-/* GCC supports format attributes */
+/* GCC support format attributes */
#if defined(__GNUC__)
#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
@@ -192,7 +192,7 @@
#endif
/* GCC and Sunpro support aligned, packed and noreturn */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#define pg_attribute_noreturn() __attribute__((noreturn))
#define pg_attribute_packed() __attribute__((packed))
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
new file mode 100644
index 0000000000..1c2d166791
--- /dev/null
+++ b/src/include/port/aix.h
@@ -0,0 +1,6 @@
+/*
+ * src/include/port/aix.h
+ */
+#define CLASS_CONFLICT
+#define DISABLE_XOPEN_NLS
+
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 29ac6cdcd9..768dbbd2e3 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -401,57 +401,16 @@ typedef unsigned int slock_t;
#define TAS(lock) tas(lock)
-/* On PPC, it's a win to use a non-locking test before the lwarx */
+/* On PPC, use the gcc atomic routines, to set the lock. */
#define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock))
-/*
- * The second operand of addi can hold a constant zero or a register number,
- * hence constraint "=&b" to avoid allocating r0. "b" stands for "address
- * base register"; most operands having this register-or-zero property are
- * address bases, e.g. the second operand of lwax.
- *
- * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
- * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
- * But if the spinlock is in ordinary memory, we can use lwsync instead for
- * better performance.
- */
static __inline__ int
tas(volatile slock_t *lock)
{
- slock_t _t;
- int _res;
-
- __asm__ __volatile__(
-" lwarx %0,0,%3,1 \n"
-" cmpwi %0,0 \n"
-" bne 1f \n"
-" addi %0,%0,1 \n"
-" stwcx. %0,0,%3 \n"
-" beq 2f \n"
-"1: \n"
-" li %1,1 \n"
-" b 3f \n"
-"2: \n"
-" lwsync \n"
-" li %1,0 \n"
-"3: \n"
-: "=&b"(_t), "=r"(_res), "+m"(*lock)
-: "r"(lock)
-: "memory", "cc");
- return _res;
+ return __sync_lock_test_and_set(lock, 1);
}
-/*
- * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
- * But we can use lwsync instead for better performance.
- */
-#define S_UNLOCK(lock) \
-do \
-{ \
- __asm__ __volatile__ (" lwsync \n" ::: "memory"); \
- *((volatile slock_t *) (lock)) = 0; \
-} while (0)
-
+#define S_UNLOCK(lock) __sync_lock_release(lock)
#endif /* powerpc */
@@ -662,6 +621,21 @@ tas(volatile slock_t *lock)
#if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
+#if defined(_AIX) /* AIX */
+/*
+ * AIX (POWER)
+ */
+#define HAS_TEST_AND_SET
+
+#include <sys/atomic_op.h>
+
+typedef int slock_t;
+
+#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
+#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
+#endif /* _AIX */
+
+
/* These are in sunstudio_(sparc|x86).s */
#if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index b36a765764..154429d4d1 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -114,7 +114,7 @@ backend_src = $(top_srcdir)/src/backend
# coding rule.
libpq-refs-stamp: $(shlib)
ifneq ($(enable_coverage), yes)
-ifeq (,$(filter solaris,$(PORTNAME)))
+ifeq (,$(filter aix solaris,$(PORTNAME)))
@if nm -A -u $< 2>/dev/null | grep -v -e __cxa_atexit -e __tsan_func_exit | grep exit; then \
echo 'libpq must not be calling any function which invokes exit'; exit 1; \
fi
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index ed2a4048d1..7e2017daf0 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -54,8 +54,9 @@ libpq_c_args = ['-DSO_MAJOR_VERSION=5']
# libpq_st, and {pgport,common}_shlib for libpq_sh
#
# We could try to avoid building the source files twice, but it probably adds
-# more complexity than its worth (reusing object files requires also linking
-# to the library on windows or breaks precompiled headers).
+# more complexity than its worth (AIX doesn't support link_whole yet, reusing
+# object files requires also linking to the library on windows or breaks
+# precompiled headers).
libpq_st = static_library('libpq',
libpq_sources,
include_directories: [libpq_inc],
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
new file mode 100644
index 0000000000..dd16a7a037
--- /dev/null
+++ b/src/makefiles/Makefile.aix
@@ -0,0 +1,39 @@
+# MAKE_EXPORTS is required for svr4 loaders that want a file of
+# symbol names to tell them what to export/import.
+MAKE_EXPORTS= true
+
+# -blibpath must contain ALL directories where we should look for libraries
+libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/usr/lib:/lib
+
+# when building with gcc, need to make sure that libgcc can be found
+ifeq ($(GCC), yes)
+libpath := $(libpath):$(dir $(shell gcc -print-libgcc-file-name))
+endif
+
+rpath = -Wl,-blibpath:'$(rpathdir)$(libpath)'
+
+LDFLAGS_SL += -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE
+
+# gcc needs to know it's building a shared lib, otherwise it'll not emit
+# correct code / link to the right support libraries
+ifeq ($(GCC), yes)
+LDFLAGS_SL += -shared
+endif
+
+# env var name to use in place of LD_LIBRARY_PATH
+ld_library_path_var = LIBPATH
+
+
+POSTGRES_IMP= postgres.imp
+
+ifdef PGXS
+BE_DLLLIBS= -Wl,-bI:$(pkglibdir)/$(POSTGRES_IMP)
+else
+BE_DLLLIBS= -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP)
+endif
+
+MKLDEXPORT_DIR=src/backend/port/aix
+MKLDEXPORT=$(top_srcdir)/$(MKLDEXPORT_DIR)/mkldexport.sh
+
+%$(DLSUFFIX): %.o
+ $(CC) $(CFLAGS) $*.o $(LDFLAGS) $(LDFLAGS_SL) -o $@ $(BE_DLLLIBS)
diff --git a/src/port/README b/src/port/README
index ed5c54a72f..97f18a6233 100644
--- a/src/port/README
+++ b/src/port/README
@@ -28,5 +28,5 @@ applications.
from libpgport are linked first. This avoids having applications
dependent on symbols that are _used_ by libpq, but not intended to be
exported by libpq. libpq's libpgport usage changes over time, so such a
-dependency is a problem. Windows, Linux, and macOS use an export
+dependency is a problem. Windows, Linux, AIX, and macOS use an export
list to control the symbols exported by libpq.
diff --git a/src/port/strerror.c b/src/port/strerror.c
index 4918ba821c..1070a49802 100644
--- a/src/port/strerror.c
+++ b/src/port/strerror.c
@@ -214,8 +214,10 @@ get_errno_symbol(int errnum)
return "ENOTCONN";
case ENOTDIR:
return "ENOTDIR";
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
case ENOTEMPTY:
return "ENOTEMPTY";
+#endif
case ENOTSOCK:
return "ENOTSOCK";
#ifdef ENOTSUP
diff --git a/src/template/aix b/src/template/aix
new file mode 100644
index 0000000000..0a788676c0
--- /dev/null
+++ b/src/template/aix
@@ -0,0 +1,14 @@
+# src/template/aix
+
+ # Due to a compiler bug, see [email protected] for details,
+ # force restrict not to be used when compiling with xlc.
+# FORCE_DISABLE_RESTRICT=yes
+#fi
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
+# Native memset() is faster, tested on:
+# AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
+# AIX 5.3 ML3, gcc 4.0.1
+MEMSET_LOOP_LIMIT=0
diff --git a/src/test/regress/Makefile b/src/test/regress/Makefile
index 6409a485e8..7c665ff892 100644
--- a/src/test/regress/Makefile
+++ b/src/test/regress/Makefile
@@ -7,6 +7,11 @@
# GNU make uses a make file named "GNUmakefile" in preference to "Makefile"
# if it exists. Postgres is shipped with a "GNUmakefile".
+
+# AIX make defaults to building *every* target of the first rule. Start with
+# a single-target, empty rule to make the other targets non-default.
+all:
+
all install clean check installcheck:
@echo "You must use GNU make to use Postgres. It may be installed"
@echo "on your system with the name 'gmake'."
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index 8370c1561c..c5c675b750 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -25,3 +25,32 @@ SELECT relname, relkind
---------+---------
(0 rows)
+--
+-- When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on
+-- some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure
+-- catalog C struct layout matches catalog tuple layout, arrange for the tuple
+-- offset of each fixed-width, attalign='d' catalog column to be divisible by 8
+-- unconditionally. Keep such columns before the first NameData column of the
+-- catalog, since packagers can override NAMEDATALEN to an odd number.
+--
+WITH check_columns AS (
+ SELECT relname, attname,
+ array(
+ SELECT t.oid
+ FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
+ WHERE pa.attrelid = a.attrelid AND
+ pa.attnum > 0 AND pa.attnum < a.attnum
+ ORDER BY pa.attnum) AS coltypes
+ FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
+ JOIN pg_namespace n ON c.relnamespace = n.oid
+ WHERE attalign = 'd' AND relkind = 'r' AND
+ attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
+)
+SELECT relname, attname, coltypes, get_columns_length(coltypes)
+ FROM check_columns
+ WHERE get_columns_length(coltypes) % 8 != 0 OR
+ 'name'::regtype::oid = ANY(coltypes);
+ relname | attname | coltypes | get_columns_length
+---------+---------+----------+--------------------
+(0 rows)
+
diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out
index 3d0eeec996..5d9e6bf12b 100644
--- a/src/test/regress/expected/test_setup.out
+++ b/src/test/regress/expected/test_setup.out
@@ -209,6 +209,10 @@ CREATE FUNCTION ttdummy ()
RETURNS trigger
AS :'regresslib'
LANGUAGE C;
+CREATE FUNCTION get_columns_length(oid[])
+ RETURNS int
+ AS :'regresslib'
+ LANGUAGE C STRICT STABLE PARALLEL SAFE;
-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines. The hash function for int4 simply returns
-- the sum of the values passed to it and the one for text returns the length
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index deffaea578..cc633864d7 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -1221,3 +1221,43 @@ binary_coercible(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
}
+
+/*
+ * Return the length of the portion of a tuple consisting of the given array
+ * of data types. The input data types must be fixed-length data types.
+ */
+PG_FUNCTION_INFO_V1(get_columns_length);
+Datum
+get_columns_length(PG_FUNCTION_ARGS)
+{
+ ArrayType *ta = PG_GETARG_ARRAYTYPE_P(0);
+ Oid *type_oids;
+ int ntypes;
+ int column_offset = 0;
+
+ if (ARR_HASNULL(ta) && array_contains_nulls(ta))
+ elog(ERROR, "argument must not contain nulls");
+
+ if (ARR_NDIM(ta) > 1)
+ elog(ERROR, "argument must be empty or one-dimensional array");
+
+ type_oids = (Oid *) ARR_DATA_PTR(ta);
+ ntypes = ArrayGetNItems(ARR_NDIM(ta), ARR_DIMS(ta));
+ for (int i = 0; i < ntypes; i++)
+ {
+ Oid typeoid = type_oids[i];
+ int16 typlen;
+ bool typbyval;
+ char typalign;
+
+ get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign);
+
+ /* the data type must be fixed-length */
+ if (typlen < 0)
+ elog(ERROR, "type %u is not fixed-length data type", typeoid);
+
+ column_offset = att_align_nominal(column_offset + typlen, typalign);
+ }
+
+ PG_RETURN_INT32(column_offset);
+}
diff --git a/src/test/regress/sql/sanity_check.sql b/src/test/regress/sql/sanity_check.sql
index 162e5324b5..7f338d191c 100644
--- a/src/test/regress/sql/sanity_check.sql
+++ b/src/test/regress/sql/sanity_check.sql
@@ -19,3 +19,29 @@ SELECT relname, relkind
FROM pg_class
WHERE relkind IN ('v', 'c', 'f', 'p', 'I')
AND relfilenode <> 0;
+
+--
+-- When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on
+-- some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure
+-- catalog C struct layout matches catalog tuple layout, arrange for the tuple
+-- offset of each fixed-width, attalign='d' catalog column to be divisible by 8
+-- unconditionally. Keep such columns before the first NameData column of the
+-- catalog, since packagers can override NAMEDATALEN to an odd number.
+--
+WITH check_columns AS (
+ SELECT relname, attname,
+ array(
+ SELECT t.oid
+ FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
+ WHERE pa.attrelid = a.attrelid AND
+ pa.attnum > 0 AND pa.attnum < a.attnum
+ ORDER BY pa.attnum) AS coltypes
+ FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
+ JOIN pg_namespace n ON c.relnamespace = n.oid
+ WHERE attalign = 'd' AND relkind = 'r' AND
+ attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
+)
+SELECT relname, attname, coltypes, get_columns_length(coltypes)
+ FROM check_columns
+ WHERE get_columns_length(coltypes) % 8 != 0 OR
+ 'name'::regtype::oid = ANY(coltypes);
diff --git a/src/test/regress/sql/test_setup.sql b/src/test/regress/sql/test_setup.sql
index 06b0e2121f..1b2d434683 100644
--- a/src/test/regress/sql/test_setup.sql
+++ b/src/test/regress/sql/test_setup.sql
@@ -257,6 +257,11 @@ CREATE FUNCTION ttdummy ()
AS :'regresslib'
LANGUAGE C;
+CREATE FUNCTION get_columns_length(oid[])
+ RETURNS int
+ AS :'regresslib'
+ LANGUAGE C STRICT STABLE PARALLEL SAFE;
+
-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines. The hash function for int4 simply returns
-- the sum of the values passed to it and the one for text returns the length
diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl
index d9fdaaaf6d..888c8a197a 100644
--- a/src/tools/gen_export.pl
+++ b/src/tools/gen_export.pl
@@ -16,11 +16,12 @@ GetOptions(
'input:s' => \$input,
'output:s' => \$output) or die "wrong arguments";
-if (not( $format eq 'darwin'
+if (not( $format eq 'aix'
+ or $format eq 'darwin'
or $format eq 'gnu'
or $format eq 'win'))
{
- die "$0: $format is not yet handled (only darwin, gnu, win are)\n";
+ die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n";
}
open(my $input_handle, '<', $input)
@@ -55,7 +56,11 @@ while (<$input_handle>)
}
elsif (/^(\S+)\s+(\S+)/)
{
- if ($format eq 'darwin')
+ if ($format eq 'aix')
+ {
+ print $output_handle "$1\n";
+ }
+ elsif ($format eq 'darwin')
{
print $output_handle "_$1\n";
}
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 4a157d0a5f..cfd8c6896c 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -85,6 +85,7 @@ do
# These files are platform-specific, and c.h will include the
# one that's relevant for our current platform anyway.
+ test "$f" = src/include/port/aix.h && continue
test "$f" = src/include/port/cygwin.h && continue
test "$f" = src/include/port/darwin.h && continue
test "$f" = src/include/port/freebsd.h && continue
--
2.41.0
[application/octet-stream] buildfarm17-summary.log (3.6K, 4-buildfarm17-summary.log)
download
[text/plain] sections-1.c (1.3K, 5-sections-1.c)
download | inline:
/* Test that all sections are touched. */
/* { dg-require-effective-target sync_int_long } */
#include <omp.h>
#include <string.h>
#include <assert.h>
#include "libgomp_g.h"
#define N 100
static int data[N];
static int NTHR;
static void clean_data (void)
{
memset (data, -1, sizeof (data));
}
static void test_data (void)
{
int i;
for (i = 0; i < N; ++i)
assert (data[i] != -1);
}
static void set_data (unsigned i, int val)
{
int old;
assert (i >= 1 && i <= N);
old = __sync_lock_test_and_set (data+i-1, val);
assert (old == -1);
}
static void f_1 (void *dummy)
{
int iam = omp_get_thread_num ();
unsigned long s;
for (s = GOMP_sections_start (N); s ; s = GOMP_sections_next ())
set_data (s, iam);
GOMP_sections_end ();
}
static void test_1 (void)
{
clean_data ();
GOMP_parallel_start (f_1, NULL, NTHR);
f_1 (NULL);
GOMP_parallel_end ();
test_data ();
}
static void f_2 (void *dummy)
{
int iam = omp_get_thread_num ();
unsigned s;
while ((s = GOMP_sections_next ()))
set_data (s, iam);
GOMP_sections_end_nowait ();
}
static void test_2 (void)
{
clean_data ();
GOMP_parallel_sections_start (f_2, NULL, NTHR, N);
f_2 (NULL);
GOMP_parallel_end ();
test_data ();
}
int main()
{
omp_set_dynamic (0);
NTHR = 4;
test_1 ();
test_2 ();
return 0;
}
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-09-11 21:57 ` Heikki Linnakangas <[email protected]>
2024-09-11 22:06 ` Re: AIX support Thomas Munro <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 2 replies; 20+ messages in thread
From: Heikki Linnakangas @ 2024-09-11 21:57 UTC (permalink / raw)
To: Srirama Kucherlapati <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
On 11/09/2024 15:38, Srirama Kucherlapati wrote:
>> I still don't understand. We have Linux powerpc systems running
>> happily in the buildfarm. They are happy with the current spinlock
>> implementation. Why is this needed? What happens without it?
>
> Not sure, by the time the below commits were made if there was a
> consideration to use the gcc routines.
The PPC asm code was originally written in 2002, and the first use of
__sync_lock_test_and_set(), for ARM, appeared in 2012. The commit that
made __sync_lock_test_and_set() be chosen automatically for platforms
that don't specify anything else was added in 2022.
> I tried to replace the AIX asm (under__ppc__ macro) with the gcc
> routine __sync_lock_test_and_set(), and all the buildfarm tests
> passed. Attached patch and the buildfarm output. Please let me know
> your feedback.
Ok, if we don't need the assembler code at all, that's good. A patch to
introduce AIX support should not change it for non-AIX powerpc systems
though. That might be a good change, but would need to be justified
separately, e.g. by some performance testing, and should be a separate
patch.
If you make no changes to s_lock.h at all, will it work? Why not?
You said earlier:
> I mean this part of the code is needed as this is specific to AIX kernel memory
> operation which is different from __sync_lock_test_and_set().
>
> I would like to mention that the changes made in src/include/storage/s_lock.h
> are pretty much required and need to be operated in assemble specific to IBM
> Power architecture.
Was that earlier statement incorrect? Is the manual wrong or outdated or
not applicable to us?
Moving on..
Do you still need mkldexport.sh? Surely there's a better way to do that
in year 2024. Some quick googling says there's a '-bexpall' option to
'ld', which kind of sounds like what we want. Will that work? How do
other programs do this?
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
@ 2024-09-11 22:06 ` Thomas Munro <[email protected]>
1 sibling, 0 replies; 20+ messages in thread
From: Thomas Munro @ 2024-09-11 22:06 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; +Cc: Srirama Kucherlapati <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
On Thu, Sep 12, 2024 at 9:57 AM Heikki Linnakangas <[email protected]> wrote:
> If you make no changes to s_lock.h at all, will it work? Why not?
It's good to keep the work independent and I don't want to hold up
anything happening in this thread, but just for information: I have
been poking around at the idea of entirely removing the old spinlock
code and pointing spin.h's function-like-macros to the atomics code.
We couldn't do that before, because atomics were sometimes implemented
with spinlocks, but now that pg_atomic_flag is never implemented with
spinlocks we can flip that around, and then have only one place where
we know how to do this stuff. What is needed for that to progress is,
I guess, to determine though assembler analysis or experimentation
across a bunch of targets that it works out at least as good...
https://www.postgresql.org/message-id/flat/CA%2BhUKGJ%2BoA%2B62iUZ-EQb5R2cAOW3Y942ZoOtzOD%3D1sQ05iNg...
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
@ 2024-09-13 11:49 ` Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
1 sibling, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-09-13 11:49 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
> The PPC asm code was originally written in 2002, and the first use of
> _ sync_lock_test_and_set(), for ARM, appeared in 2012. The commit that
> made __sync_lock_test_and_set() be chosen automatically for platforms
> that don't specify anything else was added in 2022.
Thanks for the info.
------------------
> Ok, if we don't need the assembler code at all, that's good. A patch to
> introduce AIX support should not change it for non-AIX powerpc systems
> though. That might be a good change, but would need to be justified
> separately, e.g. by some performance testing, and should be a separate
> patch.
> If you make no changes to s_lock.h at all, will it work? Why not?
With the existing asm code I see there are some syntax errors, being hit.
But after reverting the old changes the issues resolved. Below are diffs.
static __inline__ int
tas(volatile slock_t *lock)
{
@@ -424,17 +413,15 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
-" bne 1f \n"
+" bne $+16 \n" /* branch to li %1,1 */
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
-" beq 2f \n"
-"1: \n"
+" beq $+12 \n" /* branch to lwsync */
" li %1,1 \n"
-" b 3f \n"
-"2: \n"
+" b $+12 \n" /* branch to end of asm sequence */
" lwsync \n"
" li %1,0 \n"
-"3: \n"
+
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
Let me know if I need to run any perf tools to check the performance of
the __sync_lock_test_and_set change.
---------------
> > I mean this part of the code is needed as this is specific to AIX kernel memory
> > operation which is different from __sync_lock_test_and_set().
> >
> > I would like to mention that the changes made in src/include/storage/s_lock.h
> > are pretty much required and need to be operated in assemble specific to IBM
> > Power architecture.
> Was that earlier statement incorrect? Is the manual wrong or outdated or
> not applicable to us?
Here this change is specific to AIX, but since we are compiling with gcc, this
is not applicable. But I will try with __sync* routines and check.
---------------
> Do you still need mkldexport.sh? Surely there's a better way to do that
> in year 2024. Some quick googling says there's a '-bexpall' option to
> 'ld', which kind of sounds like what we want. Will that work? How do
> other programs do this?
Thanks for looking into this, I’m working on this, I will let you know.
Thanks,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-09-17 16:29 ` Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-09-17 16:29 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
> Do you still need mkldexport.sh? Surely there's a better way to do that
> in year 2024. Some quick googling says there's a '-bexpall' option to
> 'ld', which kind of sounds like what we want. Will that work? How do
> other programs do this?
We have noticed couple of caveats with these flags -bexpall/-bexpfull in other
opensource tools on AIX. This option would export too many symbols causing
problems because a shared library may re-export symbols from another library
causing confused dependencies, duplicate symbols.
We have similar discussion wrt to these flag in Cmake
https://gitlab.kitware.com/cmake/cmake/-/issues/19163
Also, I tried some sample program to verify the same as below
>> cat foo.c
#include <stdio.h>
#include <string.h>
int func1()
{
char str1[] = "Hello ", str2[] = "world! ";
strcat(str1,str2);
puts(str1);
return 0;
}
>> gcc -c foo.c -o foo.o
>> gcc -shared -Wl,-bexpall -o foo.so foo.o
>> dump -Tov foo.so
foo.so:
***Object Module Header***
# Sections Symbol Ptr # Symbols Opt Hdr Len Flags
4 0x00000d88 120 72 0x3002
Flags=( EXEC DYNLOAD SHROBJ DEP_SYSTEM )
Timestamp = "Sep 17 10:17:35 2024"
Magic = 0x1df (32-bit XCOFF)
***Optional Header***
Tsize Dsize Bsize Tstart Dstart
0x00000548 0x0000010c 0x00000004 0x10000128 0x20000670
SNloader SNentry SNtext SNtoc SNdata
0x0004 0x0000 0x0001 0x0002 0x0002
TXTalign DATAalign TOC vstamp entry
0x0005 0x0004 0x20000750 0x0001 0xffffffff
maxSTACK maxDATA SNbss magic modtype
0x00000000 0x00000000 0x0003 0x010b RE
***Loader Section***
***Loader Symbol Table Information***
[Index] Value Scn IMEX Sclass Type IMPid Name
[0] 0x2000068c .data RW SECdef [noIMid] __rtinit
[1] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) __cxa_finalize
[2] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXI_shr_o
[3] 0x00000000 undef IMP DS EXTref libgcc_s.a(shr.o) _GLOBAL__AIXD_shr_o
[4] 0x00000000 undef IMP DS EXTref libc.a(shr.o) __strtollmax
[5] 0x00000000 undef IMP DS EXTref libc.a(shr.o) puts
[6] 0x200006f4 .data EXP DS Ldef [noIMid] __init_aix_libgcc_cxa_atexit
[7] 0x20000724 .data EXP DS Ldef [noIMid] _GLOBAL__AIXI_foo_so
[8] 0x20000730 .data EXP DS Ldef [noIMid] _GLOBAL__AIXD_foo_so
>> [9] 0x2000073c .data EXP DS SECdef [noIMid] strcat
[10] 0x20000744 .data EXP DS Ldef [noIMid] func1
The code makes use of strcat from libc but re-exports the symbol (because of -bexpall).
As of now due to the limitation with these flags (-bexpall / -bexpfull ? ), the
solution here is to continue to extract the symbols from the object files and
use that export file as part of building the shared library. (Continue to use
the mkldexport.sh script to generate the export symbols).
Thanks,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-09-24 11:25 ` Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-09-24 11:25 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
Hi Heikki & team,
Could you please let me know your comments on the previous details?
Attached are the individual patches for AIX and gcc(__sync) routines.
Thanks,
Sriram.
Attachments:
[application/octet-stream] 0001-AIX-support-revert-the-changes-from-0b16bb8776bb8.v5.patch (43.9K, 3-0001-AIX-support-revert-the-changes-from-0b16bb8776bb8.v5.patch)
download | inline diff:
From f8260d015857d3a65292e55f08ec3a13b60f00b3 Mon Sep 17 00:00:00 2001
From: Sriram RK <[email protected]>
Date: Mon, 20 May 2024 01:38:59 -0500
Subject: [PATCH 1/1] AIX support, revert the changes from 0b16bb8776bb8. Trim
AIX/XLC changes to support gcc only.
- Review comments from Heikki.
- Replace tas() AIX asm with gcc __sync_lock_test_and_set().
- Fix tas() for powerPC.
- Include only AIX specific changes in s_lock.h
---
Makefile | 2 -
configure | 37 +++---
configure.ac | 28 ++---
doc/src/sgml/dfunc.sgml | 19 +++
doc/src/sgml/installation.sgml | 118 +++++++++++++++++-
doc/src/sgml/runtime.sgml | 23 ++++
meson.build | 57 +++++----
src/Makefile.shlib | 29 +++++
src/backend/Makefile | 20 +++
src/backend/meson.build | 15 +++
src/backend/port/aix/mkldexport.sh | 61 +++++++++
src/backend/utils/error/elog.c | 2 +
src/backend/utils/misc/ps_status.c | 4 +-
src/bin/pg_basebackup/t/010_pg_basebackup.pl | 3 +-
src/bin/pg_verifybackup/t/008_untar.pl | 3 +-
src/bin/pg_verifybackup/t/010_client_untar.pl | 3 +-
src/include/c.h | 4 +-
src/include/port/aix.h | 6 +
src/include/storage/s_lock.h | 25 +++-
src/interfaces/libpq/Makefile | 2 +-
src/interfaces/libpq/meson.build | 5 +-
src/makefiles/Makefile.aix | 39 ++++++
src/port/README | 2 +-
src/port/strerror.c | 2 +
src/template/aix | 14 +++
src/test/regress/Makefile | 5 +
src/test/regress/expected/sanity_check.out | 29 +++++
src/test/regress/expected/test_setup.out | 4 +
src/test/regress/regress.c | 40 ++++++
src/test/regress/sql/sanity_check.sql | 26 ++++
src/test/regress/sql/test_setup.sql | 5 +
src/tools/gen_export.pl | 11 +-
src/tools/pginclude/headerscheck | 1 +
33 files changed, 555 insertions(+), 89 deletions(-)
create mode 100755 src/backend/port/aix/mkldexport.sh
create mode 100644 src/include/port/aix.h
create mode 100644 src/makefiles/Makefile.aix
create mode 100644 src/template/aix
diff --git a/Makefile b/Makefile
index 8a2ec9396b..9bc1a4ec17 100644
--- a/Makefile
+++ b/Makefile
@@ -13,8 +13,6 @@
# AIX make defaults to building *every* target of the first rule. Start with
# a single-target, empty rule to make the other targets non-default.
-# (We don't support AIX anymore, but if someone tries to build on AIX anyway,
-# at least they'll get the instructions to run 'configure' first.)
all:
all check install installdirs installcheck installcheck-parallel uninstall clean distclean maintainer-clean dist distcheck world check-world install-world installcheck-world:
diff --git a/configure b/configure
index 89644f2249..f218b2e040 100755
--- a/configure
+++ b/configure
@@ -2988,6 +2988,7 @@ else
# --with-template not given
case $host_os in
+ aix*) template=aix ;;
cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
@@ -6848,7 +6849,6 @@ if test x"$pgac_cv_prog_CXX_cxxflags__fno_strict_aliasing" = x"yes"; then
CXXFLAGS="${CXXFLAGS} -fno-strict-aliasing"
fi
-
fi
# If the compiler knows how to hide symbols, add the switch needed for that to
@@ -12860,7 +12860,8 @@ fi
fi
-# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS;
+# also, on AIX, we may need to have openssl in LIBS for this step.
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
@@ -16951,28 +16952,18 @@ _ACEOF
# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that long's alignment is at least as strong as
-# char, short, or int. Note that we intentionally do not consider any types
-# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too
-# much of a penalty for disk and memory space.
-
-MAX_ALIGNOF=$ac_cv_alignof_double
+# We assume long's alignment is at least as strong as char, short, or int;
+# but we must check long long (if it is being used for int64) and double.
+# Note that we intentionally do not consider any types wider than 64 bits,
+# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
+# for disk and memory space.
-if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long' is greater than the alignment of 'double'" "$LINENO" 5
+MAX_ALIGNOF=$ac_cv_alignof_long
+if test $MAX_ALIGNOF -lt $ac_cv_alignof_double ; then
+ MAX_ALIGNOF=$ac_cv_alignof_double
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long long int' is greater than the alignment of 'double'" "$LINENO" 5
+if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $MAX_ALIGNOF -lt $ac_cv_alignof_long_long_int ; then
+ MAX_ALIGNOF="$ac_cv_alignof_long_long_int"
fi
cat >>confdefs.h <<_ACEOF
@@ -17090,7 +17081,7 @@ else
/* end confdefs.h. */
/* This must match the corresponding code in c.h: */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
diff --git a/configure.ac b/configure.ac
index c7322e292c..a059509cd9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,7 @@ PGAC_ARG_REQ(with, template, [NAME], [override operating system template],
# --with-template not given
case $host_os in
+ aix*) template=aix ;;
cygwin*|msys*) template=cygwin ;;
darwin*) template=darwin ;;
dragonfly*) template=netbsd ;;
@@ -1385,7 +1386,8 @@ if test "$with_zstd" = yes ; then
AC_CHECK_LIB(zstd, ZSTD_compress, [], [AC_MSG_ERROR([library 'zstd' is required for ZSTD support])])
fi
-# Note: We can test for libldap_r only after we know PTHREAD_LIBS
+# Note: We can test for libldap_r only after we know PTHREAD_LIBS;
+# also, on AIX, we may need to have openssl in LIBS for this step.
if test "$with_ldap" = yes ; then
_LIBS="$LIBS"
if test "$PORTNAME" != "win32"; then
@@ -1643,8 +1645,9 @@ PGAC_TYPE_LOCALE_T
# spelling it understands, because it conflicts with
# __declspec(restrict). Therefore we define pg_restrict to the
# appropriate definition, which presumably won't conflict.
+#
AC_C_RESTRICT
-if test "$ac_cv_c_restrict" = "no"; then
+if test "$ac_cv_c_restrict" = "no" ; then
pg_restrict=""
else
pg_restrict="$ac_cv_c_restrict"
@@ -1996,22 +1999,11 @@ fi
AC_CHECK_ALIGNOF(double)
# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that long's alignment is at least as strong as
-# char, short, or int. Note that we intentionally do not consider any types
-# wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8 would be too
-# much of a penalty for disk and memory space.
-
-MAX_ALIGNOF=$ac_cv_alignof_double
+# We assume long's alignment is at least as strong as char, short, or int;
+# but we must check long long (if it is being used for int64) and double.
+# Note that we intentionally do not consider any types wider than 64 bits,
+# as allowing MAXIMUM_ALIGNOF to exceed 8 would be too much of a penalty
+# for disk and memory space.
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
AC_MSG_ERROR([alignment of 'long' is greater than the alignment of 'double'])
diff --git a/doc/src/sgml/dfunc.sgml b/doc/src/sgml/dfunc.sgml
index b94aefcd0c..554f9fac4c 100644
--- a/doc/src/sgml/dfunc.sgml
+++ b/doc/src/sgml/dfunc.sgml
@@ -202,4 +202,23 @@ gcc -G -o foo.so foo.o
server expects to find the shared library files.
</para>
+<!--
+Under AIX, object files are compiled normally but building the shared
+library requires a couple of steps. First, create the object file:
+.nf
+cc <other flags> -c foo.c
+.fi
+You must then create a symbol \*(lqexports\*(rq file for the object
+file:
+.nf
+mkldexport foo.o `pwd` > foo.exp
+.fi
+Finally, you can create the shared library:
+.nf
+ld <other flags> -H512 -T512 -o foo.so -e _nostart \e
+ -bI:.../lib/postgres.exp -bE:foo.exp foo.o \e
+ -lm -lc 2>/dev/null
+.fi
+ -->
+
</sect2>
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 1b32d5ca62..60e9a34a03 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -3401,7 +3401,7 @@ export MANPATH
<para>
<productname>PostgreSQL</productname> can be expected to work on current
versions of these operating systems: Linux, Windows,
- FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, Solaris, and illumos.
+ FreeBSD, OpenBSD, NetBSD, DragonFlyBSD, macOS, AIX, Solaris, and illumos.
Other Unix-like systems may also work but are not currently
being tested. In most cases, all CPU architectures supported by
a given operating system will work. Look in
@@ -3445,6 +3445,122 @@ export MANPATH
installation issues.
</para>
+ <sect2 id="installation-notes-aix">
+ <title>AIX</title>
+
+ <indexterm zone="installation-notes-aix">
+ <primary>AIX</primary>
+ <secondary>installation on</secondary>
+ </indexterm>
+
+ <para>
+ You can use GCC to build <productname>PostgreSQL</productname>
+ on <productname>AIX</productname>.
+ </para>
+
+ <para>
+ <productname>AIX</productname> versions before 7.1 are no longer
+ tested nor supported by the <productname>PostgreSQL</productname>
+ community.
+ </para>
+
+ <sect3 id="installation-notes-aix-mem-management">
+ <title>Memory Management</title>
+ <!-- https://archives.postgresql.org/message-id/[email protected] -->
+
+ <para>
+ AIX can be somewhat peculiar with regards to the way it does
+ memory management. You can have a server with many multiples of
+ gigabytes of RAM free, but still get out of memory or address
+ space errors when running applications. One example
+ is loading of extensions failing with unusual errors.
+ For example, running as the owner of the PostgreSQL installation:
+<screen>
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": A memory address is not in the address space for the process.
+</screen>
+ Running as a non-owner in the group possessing the PostgreSQL
+ installation:
+<screen>
+=# CREATE EXTENSION plperl;
+ERROR: could not load library "/opt/dbs/pgsql/lib/plperl.so": Bad address
+</screen>
+ Another example is out of memory errors in the PostgreSQL server
+ logs, with every memory allocation near or greater than 256 MB
+ failing.
+ </para>
+
+ <para>
+ The overall cause of all these problems is the default bittedness
+ and memory model used by the server process. By default, all
+ binaries built on AIX are 32-bit. This does not depend upon
+ hardware type or kernel in use. These 32-bit processes are
+ limited to 4 GB of memory laid out in 256 MB segments using one
+ of a few models. The default allows for less than 256 MB in the
+ heap as it shares a single segment with the stack.
+ </para>
+
+ <para>
+ In the case of the <literal>plperl</literal> example, above,
+ check your umask and the permissions of the binaries in your
+ PostgreSQL installation. The binaries involved in that example
+ were 32-bit and installed as mode 750 instead of 755. Due to the
+ permissions being set in this fashion, only the owner or a member
+ of the possessing group can load the library. Since it isn't
+ world-readable, the loader places the object into the process'
+ heap instead of the shared library segments where it would
+ otherwise be placed.
+ </para>
+
+ <para>
+ The <quote>ideal</quote> solution for this is to use a 64-bit
+ build of PostgreSQL, but that is not always practical, because
+ systems with 32-bit processors can build, but not run, 64-bit
+ binaries.
+ </para>
+
+ <para>
+ If a 32-bit binary is desired, set <symbol>LDR_CNTRL</symbol> to
+ <literal>MAXDATA=0x<replaceable>n</replaceable>0000000</literal>,
+ where 1 <= n <= 8, before starting the PostgreSQL server,
+ and try different values and <filename>postgresql.conf</filename>
+ settings to find a configuration that works satisfactorily. This
+ use of <symbol>LDR_CNTRL</symbol> tells AIX that you want the
+ server to have <symbol>MAXDATA</symbol> bytes set aside for the
+ heap, allocated in 256 MB segments. When you find a workable
+ configuration,
+ <command>ldedit</command> can be used to modify the binaries so
+ that they default to using the desired heap size. PostgreSQL can
+ also be rebuilt, passing <literal>configure
+ LDFLAGS="-Wl,-bmaxdata:0x<replaceable>n</replaceable>0000000"</literal>
+ to achieve the same effect.
+ </para>
+
+ <para>
+ For a 64-bit build, set <envar>OBJECT_MODE</envar> to 64 and
+ pass <literal>CC="gcc -maix64"</literal>
+ and <literal>LDFLAGS="-Wl,-bbigtoc"</literal>
+ to <command>configure</command>.
+ If you omit the export of
+ <envar>OBJECT_MODE</envar>, your build may fail with linker errors. When
+ <envar>OBJECT_MODE</envar> is set, it tells AIX's build utilities
+ such as <command>ar</command>, <command>as</command>, and <command>ld</command> what
+ type of objects to default to handling.
+ </para>
+
+ <para>
+ By default, overcommit of paging space can happen. While we have
+ not seen this occur, AIX will kill processes when it runs out of
+ memory and the overcommit is accessed. The closest to this that
+ we have seen is fork failing because the system decided that
+ there was not enough memory for another process. Like many other
+ parts of AIX, the paging space allocation method and
+ out-of-memory kill is configurable on a system- or process-wide
+ basis if this becomes a problem.
+ </para>
+ </sect3>
+ </sect2>
+
<sect2 id="installation-notes-cygwin">
<title>Cygwin</title>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 6047b8171d..64753d9c01 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -891,6 +891,29 @@ psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such
<variablelist>
+ <varlistentry>
+ <term><systemitem class="osname">AIX</systemitem>
+ <indexterm><primary>AIX</primary><secondary>IPC configuration</secondary></indexterm>
+ </term>
+ <listitem>
+ <para>
+ It should not be necessary to do
+ any special configuration for such parameters as
+ <varname>SHMMAX</varname>, as it appears this is configured to
+ allow all memory to be used as shared memory. That is the
+ sort of configuration commonly used for other databases such
+ as <application>DB/2</application>.</para>
+
+ <para> It might, however, be necessary to modify the global
+ <command>ulimit</command> information in
+ <filename>/etc/security/limits</filename>, as the default hard
+ limits for file sizes (<varname>fsize</varname>) and numbers of
+ files (<varname>nofiles</varname>) might be too low.
+ </para>
+ </listitem>
+ </varlistentry>
+
+
<varlistentry>
<term><systemitem class="osname">FreeBSD</systemitem>
<indexterm><primary>FreeBSD</primary><secondary>IPC configuration</secondary></indexterm>
diff --git a/meson.build b/meson.build
index 1c0579d5a6..f1ac154cdc 100644
--- a/meson.build
+++ b/meson.build
@@ -196,7 +196,26 @@ endif
# that purpose.
portname = host_system
-if host_system == 'cygwin'
+if host_system == 'aix'
+ library_path_var = 'LIBPATH'
+
+ export_file_format = 'aix'
+ export_fmt = '-Wl,-bE:@0@'
+ mod_link_args_fmt = ['-Wl,-bI:@0@']
+ mod_link_with_dir = 'libdir'
+ mod_link_with_name = '@[email protected]'
+
+ # M:SRE sets a flag indicating that an object is a shared library. Seems to
+ # work in some circumstances without, but required in others.
+ ldflags_sl += '-Wl,-bM:SRE'
+ ldflags_be += '-Wl,-brtllib'
+
+ # Native memset() is faster, tested on:
+ # - AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
+ # - AIX 5.3 ML3, gcc 4.0.1
+ memset_loop_limit = 0
+
+elif host_system == 'cygwin'
sema_kind = 'unnamed_posix'
cppflags += '-D_GNU_SOURCE'
dlsuffix = '.dll'
@@ -1490,11 +1509,11 @@ sizeof_long = cc.sizeof('long', args: test_c_args)
cdata.set('SIZEOF_LONG', sizeof_long)
if sizeof_long == 8
cdata.set('HAVE_LONG_INT_64', 1)
- pg_int64_type = 'long int'
+ cdata.set('PG_INT64_TYPE', 'long int')
cdata.set_quoted('INT64_MODIFIER', 'l')
elif sizeof_long == 4 and cc.sizeof('long long', args: test_c_args) == 8
cdata.set('HAVE_LONG_LONG_INT_64', 1)
- pg_int64_type = 'long long int'
+ cdata.set('PG_INT64_TYPE', 'long long int')
cdata.set_quoted('INT64_MODIFIER', 'll')
else
error('do not know how to get a 64bit int')
@@ -1508,31 +1527,15 @@ endif
# Determine memory alignment requirements for the basic C data types.
alignof_types = ['short', 'int', 'long', 'double']
+maxalign = 0
foreach t : alignof_types
align = cc.alignment(t, args: test_c_args)
+ if maxalign < align
+ maxalign = align
+ endif
cdata.set('ALIGNOF_@0@'.format(t.to_upper()), align)
endforeach
-
-# Compute maximum alignment of any basic type.
-#
-# We require 'double' to have the strictest alignment among the basic types,
-# because otherwise the C ABI might impose 8-byte alignment on some of the
-# other C types that correspond to TYPALIGN_DOUBLE SQL types. That could
-# cause a mismatch between the tuple layout and the C struct layout of a
-# catalog tuple. We used to carefully order catalog columns such that any
-# fixed-width, attalign=4 columns were at offsets divisible by 8 regardless
-# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
-# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
-#
-# We assume without checking that int64's alignment is at least as strong
-# as long, char, short, or int. Note that we intentionally do not consider
-# any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8
-# would be too much of a penalty for disk and memory space.
-alignof_double = cdata.get('ALIGNOF_DOUBLE')
-if cc.alignment(pg_int64_type, args: test_c_args) > alignof_double
- error('alignment of int64 is greater than the alignment of double')
-endif
-cdata.set('MAXIMUM_ALIGNOF', alignof_double)
+cdata.set('MAXIMUM_ALIGNOF', maxalign)
cdata.set('SIZEOF_VOID_P', cc.sizeof('void *', args: test_c_args))
cdata.set('SIZEOF_SIZE_T', cc.sizeof('size_t', args: test_c_args))
@@ -1581,7 +1584,7 @@ if cc.links('''
if not meson.is_cross_build()
r = cc.run('''
/* This must match the corresponding code in c.h: */
- #if defined(__GNUC__) || defined(__SUNPRO_C)
+ #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
@@ -2476,6 +2479,10 @@ endif
# conflict.
#
# We assume C99 support, so we don't need to make this conditional.
+#
+# XXX: Historically we allowed platforms to disable restrict in template
+# files, but that was only added for AIX when building with XLC, which we
+# don't support yet.
cdata.set('pg_restrict', '__restrict')
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index fa81f6ffdd..8ca51ca03f 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -106,6 +106,20 @@ ifdef SO_MAJOR_VERSION
override CPPFLAGS += -DSO_MAJOR_VERSION=$(SO_MAJOR_VERSION)
endif
+ifeq ($(PORTNAME), aix)
+ LINK.shared = $(COMPILER)
+ ifdef SO_MAJOR_VERSION
+ shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
+ endif
+ haslibarule = yes
+ # $(exports_file) is also usable as an import file
+ exports_file = lib$(NAME).exp
+ BUILD.exports = ( echo '\#! $(shlib)'; $(AWK) '/^[^\#]/ {printf "%s\n",$$1}' $< ) > $@
+ ifneq (,$(SHLIB_EXPORTS))
+ LINK.shared += -Wl,-bE:$(exports_file)
+ endif
+endif
+
ifeq ($(PORTNAME), darwin)
ifdef soname
# linkable library
@@ -254,6 +268,14 @@ $(stlib): $(OBJS) | $(SHLIB_PREREQS)
touch $@
endif #haslibarule
+# AIX wraps shared libraries inside a static library, can be used both
+# for static and shared linking
+ifeq ($(PORTNAME), aix)
+$(stlib): $(shlib)
+ rm -f $(stlib)
+ $(AR) $(AROPT) $(stlib) $(shlib)
+endif # aix
+
ifeq (,$(filter cygwin win32,$(PORTNAME)))
# Normal case
@@ -267,8 +289,11 @@ ifneq ($(shlib), $(shlib_major))
endif
# Make sure we have a link to a name without any version numbers
ifneq ($(shlib), $(shlib_bare))
+# except on AIX, where that's not a thing
+ifneq ($(PORTNAME), aix)
rm -f $(shlib_bare)
$(LN_S) $(shlib) $(shlib_bare)
+endif # aix
endif # shlib_bare
endif # shlib_major
@@ -376,6 +401,9 @@ install-lib-static: $(stlib) installdirs-lib
install-lib-shared: $(shlib) installdirs-lib
ifdef soname
+# we don't install $(shlib) on AIX
+# (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at)
+ifneq ($(PORTNAME), aix)
$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
@@ -391,6 +419,7 @@ ifneq ($(shlib), $(shlib_bare))
endif
endif # not win32
endif # not cygwin
+endif # not aix
ifneq (,$(findstring $(PORTNAME),win32 cygwin))
$(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
endif
diff --git a/src/backend/Makefile b/src/backend/Makefile
index 6700aec039..954b14962f 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -62,12 +62,14 @@ all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(
ifneq ($(PORTNAME), cygwin)
ifneq ($(PORTNAME), win32)
+ifneq ($(PORTNAME), aix)
postgres: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
endif
endif
+endif
ifeq ($(PORTNAME), cygwin)
@@ -94,6 +96,24 @@ libpostgres.a: postgres
endif # win32
+ifeq ($(PORTNAME), aix)
+
+postgres: $(POSTGRES_IMP)
+ $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
+
+# Linking to a single .o with -r is a lot faster than building a .a or passing
+# all objects to MKLDEXPORT.
+#
+# It looks alluring to use $(CC) -r instead of ld -r, but that doesn't
+# trivially work with gcc, due to gcc specific static libraries linked in with
+# -r.
+$(POSTGRES_IMP): $(OBJS)
+ ld -r -o SUBSYS.o $(call expand_subsys,$^)
+ $(MKLDEXPORT) SUBSYS.o . > $@
+ @rm -f SUBSYS.o
+
+endif # aix
+
$(top_builddir)/src/port/libpgport_srv.a: | submake-libpgport
diff --git a/src/backend/meson.build b/src/backend/meson.build
index 436c04af08..8767aaba67 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -91,6 +91,21 @@ if cc.get_id() == 'msvc'
# be restricted to b_pch=true.
backend_link_with += postgres_lib
+elif host_system == 'aix'
+ # The '.' argument leads mkldexport.sh to emit "#! .", which refers to the
+ # main executable, allowing extension libraries to resolve their undefined
+ # symbols to symbols in the postgres binary.
+ postgres_imp = custom_target('postgres.imp',
+ command: [files('port/aix/mkldexport.sh'), '@INPUT@', '.'],
+ input: postgres_lib,
+ output: 'postgres.imp',
+ capture: true,
+ install: true,
+ install_dir: dir_lib,
+ build_by_default: false,
+ )
+ backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path())
+ backend_link_depends += postgres_imp
endif
backend_input = []
diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh
new file mode 100755
index 0000000000..adf3793e86
--- /dev/null
+++ b/src/backend/port/aix/mkldexport.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# mkldexport
+# create an AIX exports file from an object file
+#
+# src/backend/port/aix/mkldexport.sh
+#
+# Usage:
+# mkldexport objectfile [location]
+# where
+# objectfile is the current location of the object file.
+# location is the eventual (installed) location of the
+# object file (if different from the current
+# working directory).
+#
+# [This file comes from the Postgres 4.2 distribution. - ay 7/95]
+#
+# Header: /usr/local/devel/postgres/src/tools/mkldexport/RCS/mkldexport.sh,v 1.2 1994/03/13 04:59:12 aoki Exp
+#
+
+# setting this to nm -B might be better
+# ... due to changes in AIX 4.x ...
+# ... let us search in different directories - Gerhard Reithofer
+if [ -x /usr/ucb/nm ]
+then NM=/usr/ucb/nm
+elif [ -x /usr/bin/nm ]
+then NM=/usr/bin/nm
+elif [ -x /usr/ccs/bin/nm ]
+then NM=/usr/ccs/bin/nm
+elif [ -x /usr/usg/bin/nm ]
+then NM=/usr/usg/bin/nm
+else echo "Fatal error: cannot find `nm' ... please check your installation."
+ exit 1
+fi
+
+CMDNAME=`basename $0`
+if [ -z "$1" ]; then
+ echo "Usage: $CMDNAME object [location]"
+ exit 1
+fi
+OBJNAME=`basename $1`
+if [ "`basename $OBJNAME`" != "`basename $OBJNAME .o`" ]; then
+ OBJNAME=`basename $OBJNAME .o`.so
+fi
+if [ -z "$2" ]; then
+ echo '#!'
+else
+ if [ "$2" = "." ]; then
+ # for the base executable (AIX 4.2 and up)
+ echo '#! .'
+ else
+ echo '#!' $2
+ fi
+fi
+$NM -BCg $1 | \
+ egrep ' [TDB] ' | \
+ sed -e 's/.* //' | \
+ egrep -v '\$' | \
+ sed -e 's/^[.]//' | \
+ sort | \
+ uniq
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index d91a85cb2d..7b51e94f4a 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -908,7 +908,9 @@ errcode_for_file_access(void)
/* Wrong object type or state */
case ENOTDIR: /* Not a directory */
case EISDIR: /* Is a directory */
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
case ENOTEMPTY: /* Directory not empty */
+#endif
edata->sqlerrcode = ERRCODE_WRONG_OBJECT_TYPE;
break;
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index 9da6377402..532eac31b4 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -50,7 +50,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
#define PS_USE_SETPROCTITLE_FAST
#elif defined(HAVE_SETPROCTITLE)
#define PS_USE_SETPROCTITLE
-#elif defined(__linux__) || defined(__sun) || defined(__darwin__)
+#elif defined(__linux__) || defined(_AIX) || defined(__sun) || defined(__darwin__)
#define PS_USE_CLOBBER_ARGV
#elif defined(WIN32)
#define PS_USE_WIN32
@@ -60,7 +60,7 @@ bool update_process_title = DEFAULT_UPDATE_PROCESS_TITLE;
/* Different systems want the buffer padded differently */
-#if defined(__linux__) || defined(__darwin__)
+#if defined(_AIX) || defined(__linux__) || defined(__darwin__)
#define PS_PADDING '\0'
#else
#define PS_PADDING ' '
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 2d4b75a6fe..ce936959c1 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -401,7 +401,8 @@ SKIP:
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/bin/pg_verifybackup/t/008_untar.pl b/src/bin/pg_verifybackup/t/008_untar.pl
index 7a09f3b75b..30d9f3f7f0 100644
--- a/src/bin/pg_verifybackup/t/008_untar.pl
+++ b/src/bin/pg_verifybackup/t/008_untar.pl
@@ -104,7 +104,8 @@ for my $tc (@test_configuration)
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/bin/pg_verifybackup/t/010_client_untar.pl b/src/bin/pg_verifybackup/t/010_client_untar.pl
index 8c076d46de..45010d79ac 100644
--- a/src/bin/pg_verifybackup/t/010_client_untar.pl
+++ b/src/bin/pg_verifybackup/t/010_client_untar.pl
@@ -134,7 +134,8 @@ for my $tc (@test_configuration)
{
my $tar = $ENV{TAR};
# don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
+ # cases such as AIX. If tar doesn't work the init_from_backup below
+ # will fail.
skip "no tar program available", 1
if (!defined $tar || $tar eq '');
diff --git a/src/include/c.h b/src/include/c.h
index dc1841346c..641cd9bdf1 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -182,7 +182,7 @@
#define PG_USED_FOR_ASSERTS_ONLY pg_attribute_unused()
#endif
-/* GCC supports format attributes */
+/* GCC support format attributes */
#if defined(__GNUC__)
#define pg_attribute_format_arg(a) __attribute__((format_arg(a)))
#define pg_attribute_printf(f,a) __attribute__((format(PG_PRINTF_ATTRIBUTE, f, a)))
@@ -192,7 +192,7 @@
#endif
/* GCC and Sunpro support aligned, packed and noreturn */
-#if defined(__GNUC__) || defined(__SUNPRO_C)
+#if defined(__GNUC__) || defined(__SUNPRO_C)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#define pg_attribute_noreturn() __attribute__((noreturn))
#define pg_attribute_packed() __attribute__((packed))
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
new file mode 100644
index 0000000000..1c2d166791
--- /dev/null
+++ b/src/include/port/aix.h
@@ -0,0 +1,6 @@
+/*
+ * src/include/port/aix.h
+ */
+#define CLASS_CONFLICT
+#define DISABLE_XOPEN_NLS
+
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 29ac6cdcd9..2f6eb5df2a 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -424,17 +424,15 @@ tas(volatile slock_t *lock)
__asm__ __volatile__(
" lwarx %0,0,%3,1 \n"
" cmpwi %0,0 \n"
-" bne 1f \n"
+" bne $+16 \n" /* branch to li %1,1 */
" addi %0,%0,1 \n"
" stwcx. %0,0,%3 \n"
-" beq 2f \n"
-"1: \n"
+" beq $+12 \n" /* branch to lwsync */
" li %1,1 \n"
-" b 3f \n"
-"2: \n"
+" b $+12 \n" /* branch to end of asm sequence */
" lwsync \n"
" li %1,0 \n"
-"3: \n"
+
: "=&b"(_t), "=r"(_res), "+m"(*lock)
: "r"(lock)
: "memory", "cc");
@@ -662,6 +660,21 @@ tas(volatile slock_t *lock)
#if !defined(HAS_TEST_AND_SET) /* We didn't trigger above, let's try here */
+#if defined(_AIX) /* AIX */
+/*
+ * AIX (POWER)
+ */
+#define HAS_TEST_AND_SET
+
+#include <sys/atomic_op.h>
+
+typedef int slock_t;
+
+#define TAS(lock) _check_lock((slock_t *) (lock), 0, 1)
+#define S_UNLOCK(lock) _clear_lock((slock_t *) (lock), 0)
+#endif /* _AIX */
+
+
/* These are in sunstudio_(sparc|x86).s */
#if defined(__SUNPRO_C) && (defined(__i386) || defined(__x86_64__) || defined(__sparc__) || defined(__sparc))
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index b36a765764..154429d4d1 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -114,7 +114,7 @@ backend_src = $(top_srcdir)/src/backend
# coding rule.
libpq-refs-stamp: $(shlib)
ifneq ($(enable_coverage), yes)
-ifeq (,$(filter solaris,$(PORTNAME)))
+ifeq (,$(filter aix solaris,$(PORTNAME)))
@if nm -A -u $< 2>/dev/null | grep -v -e __cxa_atexit -e __tsan_func_exit | grep exit; then \
echo 'libpq must not be calling any function which invokes exit'; exit 1; \
fi
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index ed2a4048d1..7e2017daf0 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -54,8 +54,9 @@ libpq_c_args = ['-DSO_MAJOR_VERSION=5']
# libpq_st, and {pgport,common}_shlib for libpq_sh
#
# We could try to avoid building the source files twice, but it probably adds
-# more complexity than its worth (reusing object files requires also linking
-# to the library on windows or breaks precompiled headers).
+# more complexity than its worth (AIX doesn't support link_whole yet, reusing
+# object files requires also linking to the library on windows or breaks
+# precompiled headers).
libpq_st = static_library('libpq',
libpq_sources,
include_directories: [libpq_inc],
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
new file mode 100644
index 0000000000..dd16a7a037
--- /dev/null
+++ b/src/makefiles/Makefile.aix
@@ -0,0 +1,39 @@
+# MAKE_EXPORTS is required for svr4 loaders that want a file of
+# symbol names to tell them what to export/import.
+MAKE_EXPORTS= true
+
+# -blibpath must contain ALL directories where we should look for libraries
+libpath := $(shell echo $(subst -L,:,$(filter -L/%,$(LDFLAGS))) | sed -e's/ //g'):/usr/lib:/lib
+
+# when building with gcc, need to make sure that libgcc can be found
+ifeq ($(GCC), yes)
+libpath := $(libpath):$(dir $(shell gcc -print-libgcc-file-name))
+endif
+
+rpath = -Wl,-blibpath:'$(rpathdir)$(libpath)'
+
+LDFLAGS_SL += -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE
+
+# gcc needs to know it's building a shared lib, otherwise it'll not emit
+# correct code / link to the right support libraries
+ifeq ($(GCC), yes)
+LDFLAGS_SL += -shared
+endif
+
+# env var name to use in place of LD_LIBRARY_PATH
+ld_library_path_var = LIBPATH
+
+
+POSTGRES_IMP= postgres.imp
+
+ifdef PGXS
+BE_DLLLIBS= -Wl,-bI:$(pkglibdir)/$(POSTGRES_IMP)
+else
+BE_DLLLIBS= -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP)
+endif
+
+MKLDEXPORT_DIR=src/backend/port/aix
+MKLDEXPORT=$(top_srcdir)/$(MKLDEXPORT_DIR)/mkldexport.sh
+
+%$(DLSUFFIX): %.o
+ $(CC) $(CFLAGS) $*.o $(LDFLAGS) $(LDFLAGS_SL) -o $@ $(BE_DLLLIBS)
diff --git a/src/port/README b/src/port/README
index ed5c54a72f..97f18a6233 100644
--- a/src/port/README
+++ b/src/port/README
@@ -28,5 +28,5 @@ applications.
from libpgport are linked first. This avoids having applications
dependent on symbols that are _used_ by libpq, but not intended to be
exported by libpq. libpq's libpgport usage changes over time, so such a
-dependency is a problem. Windows, Linux, and macOS use an export
+dependency is a problem. Windows, Linux, AIX, and macOS use an export
list to control the symbols exported by libpq.
diff --git a/src/port/strerror.c b/src/port/strerror.c
index 4918ba821c..1070a49802 100644
--- a/src/port/strerror.c
+++ b/src/port/strerror.c
@@ -214,8 +214,10 @@ get_errno_symbol(int errnum)
return "ENOTCONN";
case ENOTDIR:
return "ENOTDIR";
+#if defined(ENOTEMPTY) && (ENOTEMPTY != EEXIST) /* same code on AIX */
case ENOTEMPTY:
return "ENOTEMPTY";
+#endif
case ENOTSOCK:
return "ENOTSOCK";
#ifdef ENOTSUP
diff --git a/src/template/aix b/src/template/aix
new file mode 100644
index 0000000000..0a788676c0
--- /dev/null
+++ b/src/template/aix
@@ -0,0 +1,14 @@
+# src/template/aix
+
+ # Due to a compiler bug, see [email protected] for details,
+ # force restrict not to be used when compiling with xlc.
+# FORCE_DISABLE_RESTRICT=yes
+#fi
+
+# Extra CFLAGS for code that will go into a shared library
+CFLAGS_SL=""
+
+# Native memset() is faster, tested on:
+# AIX 5.1 and 5.2, XLC 6.0 (IBM's cc)
+# AIX 5.3 ML3, gcc 4.0.1
+MEMSET_LOOP_LIMIT=0
diff --git a/src/test/regress/Makefile b/src/test/regress/Makefile
index 6409a485e8..7c665ff892 100644
--- a/src/test/regress/Makefile
+++ b/src/test/regress/Makefile
@@ -7,6 +7,11 @@
# GNU make uses a make file named "GNUmakefile" in preference to "Makefile"
# if it exists. Postgres is shipped with a "GNUmakefile".
+
+# AIX make defaults to building *every* target of the first rule. Start with
+# a single-target, empty rule to make the other targets non-default.
+all:
+
all install clean check installcheck:
@echo "You must use GNU make to use Postgres. It may be installed"
@echo "on your system with the name 'gmake'."
diff --git a/src/test/regress/expected/sanity_check.out b/src/test/regress/expected/sanity_check.out
index 8370c1561c..c5c675b750 100644
--- a/src/test/regress/expected/sanity_check.out
+++ b/src/test/regress/expected/sanity_check.out
@@ -25,3 +25,32 @@ SELECT relname, relkind
---------+---------
(0 rows)
+--
+-- When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on
+-- some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure
+-- catalog C struct layout matches catalog tuple layout, arrange for the tuple
+-- offset of each fixed-width, attalign='d' catalog column to be divisible by 8
+-- unconditionally. Keep such columns before the first NameData column of the
+-- catalog, since packagers can override NAMEDATALEN to an odd number.
+--
+WITH check_columns AS (
+ SELECT relname, attname,
+ array(
+ SELECT t.oid
+ FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
+ WHERE pa.attrelid = a.attrelid AND
+ pa.attnum > 0 AND pa.attnum < a.attnum
+ ORDER BY pa.attnum) AS coltypes
+ FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
+ JOIN pg_namespace n ON c.relnamespace = n.oid
+ WHERE attalign = 'd' AND relkind = 'r' AND
+ attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
+)
+SELECT relname, attname, coltypes, get_columns_length(coltypes)
+ FROM check_columns
+ WHERE get_columns_length(coltypes) % 8 != 0 OR
+ 'name'::regtype::oid = ANY(coltypes);
+ relname | attname | coltypes | get_columns_length
+---------+---------+----------+--------------------
+(0 rows)
+
diff --git a/src/test/regress/expected/test_setup.out b/src/test/regress/expected/test_setup.out
index 3d0eeec996..5d9e6bf12b 100644
--- a/src/test/regress/expected/test_setup.out
+++ b/src/test/regress/expected/test_setup.out
@@ -209,6 +209,10 @@ CREATE FUNCTION ttdummy ()
RETURNS trigger
AS :'regresslib'
LANGUAGE C;
+CREATE FUNCTION get_columns_length(oid[])
+ RETURNS int
+ AS :'regresslib'
+ LANGUAGE C STRICT STABLE PARALLEL SAFE;
-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines. The hash function for int4 simply returns
-- the sum of the values passed to it and the one for text returns the length
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c
index deffaea578..cc633864d7 100644
--- a/src/test/regress/regress.c
+++ b/src/test/regress/regress.c
@@ -1221,3 +1221,43 @@ binary_coercible(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(IsBinaryCoercible(srctype, targettype));
}
+
+/*
+ * Return the length of the portion of a tuple consisting of the given array
+ * of data types. The input data types must be fixed-length data types.
+ */
+PG_FUNCTION_INFO_V1(get_columns_length);
+Datum
+get_columns_length(PG_FUNCTION_ARGS)
+{
+ ArrayType *ta = PG_GETARG_ARRAYTYPE_P(0);
+ Oid *type_oids;
+ int ntypes;
+ int column_offset = 0;
+
+ if (ARR_HASNULL(ta) && array_contains_nulls(ta))
+ elog(ERROR, "argument must not contain nulls");
+
+ if (ARR_NDIM(ta) > 1)
+ elog(ERROR, "argument must be empty or one-dimensional array");
+
+ type_oids = (Oid *) ARR_DATA_PTR(ta);
+ ntypes = ArrayGetNItems(ARR_NDIM(ta), ARR_DIMS(ta));
+ for (int i = 0; i < ntypes; i++)
+ {
+ Oid typeoid = type_oids[i];
+ int16 typlen;
+ bool typbyval;
+ char typalign;
+
+ get_typlenbyvalalign(typeoid, &typlen, &typbyval, &typalign);
+
+ /* the data type must be fixed-length */
+ if (typlen < 0)
+ elog(ERROR, "type %u is not fixed-length data type", typeoid);
+
+ column_offset = att_align_nominal(column_offset + typlen, typalign);
+ }
+
+ PG_RETURN_INT32(column_offset);
+}
diff --git a/src/test/regress/sql/sanity_check.sql b/src/test/regress/sql/sanity_check.sql
index 162e5324b5..7f338d191c 100644
--- a/src/test/regress/sql/sanity_check.sql
+++ b/src/test/regress/sql/sanity_check.sql
@@ -19,3 +19,29 @@ SELECT relname, relkind
FROM pg_class
WHERE relkind IN ('v', 'c', 'f', 'p', 'I')
AND relfilenode <> 0;
+
+--
+-- When ALIGNOF_DOUBLE==4 (e.g. AIX), the C ABI may impose 8-byte alignment on
+-- some of the C types that correspond to TYPALIGN_DOUBLE SQL types. To ensure
+-- catalog C struct layout matches catalog tuple layout, arrange for the tuple
+-- offset of each fixed-width, attalign='d' catalog column to be divisible by 8
+-- unconditionally. Keep such columns before the first NameData column of the
+-- catalog, since packagers can override NAMEDATALEN to an odd number.
+--
+WITH check_columns AS (
+ SELECT relname, attname,
+ array(
+ SELECT t.oid
+ FROM pg_type t JOIN pg_attribute pa ON t.oid = pa.atttypid
+ WHERE pa.attrelid = a.attrelid AND
+ pa.attnum > 0 AND pa.attnum < a.attnum
+ ORDER BY pa.attnum) AS coltypes
+ FROM pg_attribute a JOIN pg_class c ON c.oid = attrelid
+ JOIN pg_namespace n ON c.relnamespace = n.oid
+ WHERE attalign = 'd' AND relkind = 'r' AND
+ attnotnull AND attlen <> -1 AND n.nspname = 'pg_catalog'
+)
+SELECT relname, attname, coltypes, get_columns_length(coltypes)
+ FROM check_columns
+ WHERE get_columns_length(coltypes) % 8 != 0 OR
+ 'name'::regtype::oid = ANY(coltypes);
diff --git a/src/test/regress/sql/test_setup.sql b/src/test/regress/sql/test_setup.sql
index 06b0e2121f..1b2d434683 100644
--- a/src/test/regress/sql/test_setup.sql
+++ b/src/test/regress/sql/test_setup.sql
@@ -257,6 +257,11 @@ CREATE FUNCTION ttdummy ()
AS :'regresslib'
LANGUAGE C;
+CREATE FUNCTION get_columns_length(oid[])
+ RETURNS int
+ AS :'regresslib'
+ LANGUAGE C STRICT STABLE PARALLEL SAFE;
+
-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines. The hash function for int4 simply returns
-- the sum of the values passed to it and the one for text returns the length
diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl
index d9fdaaaf6d..888c8a197a 100644
--- a/src/tools/gen_export.pl
+++ b/src/tools/gen_export.pl
@@ -16,11 +16,12 @@ GetOptions(
'input:s' => \$input,
'output:s' => \$output) or die "wrong arguments";
-if (not( $format eq 'darwin'
+if (not( $format eq 'aix'
+ or $format eq 'darwin'
or $format eq 'gnu'
or $format eq 'win'))
{
- die "$0: $format is not yet handled (only darwin, gnu, win are)\n";
+ die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n";
}
open(my $input_handle, '<', $input)
@@ -55,7 +56,11 @@ while (<$input_handle>)
}
elsif (/^(\S+)\s+(\S+)/)
{
- if ($format eq 'darwin')
+ if ($format eq 'aix')
+ {
+ print $output_handle "$1\n";
+ }
+ elsif ($format eq 'darwin')
{
print $output_handle "_$1\n";
}
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index 4a157d0a5f..cfd8c6896c 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -85,6 +85,7 @@ do
# These files are platform-specific, and c.h will include the
# one that's relevant for our current platform anyway.
+ test "$f" = src/include/port/aix.h && continue
test "$f" = src/include/port/cygwin.h && continue
test "$f" = src/include/port/darwin.h && continue
test "$f" = src/include/port/freebsd.h && continue
--
2.41.0
[application/octet-stream] 0001-Replace-tas-asm-with-gcc-routines-for-powerPC-implem.patch (2.3K, 4-0001-Replace-tas-asm-with-gcc-routines-for-powerPC-implem.patch)
download | inline diff:
From a08fbe47316034c458fcfb748efd7caabad9893f Mon Sep 17 00:00:00 2001
From: Sriram RK <[email protected]>
Date: Tue, 24 Sep 2024 05:04:51 -0500
Subject: [PATCH 1/1] Replace tas() asm with gcc routines for powerPC
implementaion in s_lock.h .
---
src/include/storage/s_lock.h | 43 ++++--------------------------------
1 file changed, 4 insertions(+), 39 deletions(-)
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 2f6eb5df2a..c0cc7bd38b 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -401,54 +401,19 @@ typedef unsigned int slock_t;
#define TAS(lock) tas(lock)
-/* On PPC, it's a win to use a non-locking test before the lwarx */
+/* On PPC, use the gcc atomic routines, to set the lock. */
#define TAS_SPIN(lock) (*(lock) ? 1 : TAS(lock))
-/*
- * The second operand of addi can hold a constant zero or a register number,
- * hence constraint "=&b" to avoid allocating r0. "b" stands for "address
- * base register"; most operands having this register-or-zero property are
- * address bases, e.g. the second operand of lwax.
- *
- * NOTE: per the Enhanced PowerPC Architecture manual, v1.0 dated 7-May-2002,
- * an isync is a sufficient synchronization barrier after a lwarx/stwcx loop.
- * But if the spinlock is in ordinary memory, we can use lwsync instead for
- * better performance.
- */
static __inline__ int
tas(volatile slock_t *lock)
{
- slock_t _t;
- int _res;
-
- __asm__ __volatile__(
-" lwarx %0,0,%3,1 \n"
-" cmpwi %0,0 \n"
-" bne $+16 \n" /* branch to li %1,1 */
-" addi %0,%0,1 \n"
-" stwcx. %0,0,%3 \n"
-" beq $+12 \n" /* branch to lwsync */
-" li %1,1 \n"
-" b $+12 \n" /* branch to end of asm sequence */
-" lwsync \n"
-" li %1,0 \n"
-
-: "=&b"(_t), "=r"(_res), "+m"(*lock)
-: "r"(lock)
-: "memory", "cc");
- return _res;
+ return __sync_lock_test_and_set(lock, 1);
}
/*
- * PowerPC S_UNLOCK is almost standard but requires a "sync" instruction.
- * But we can use lwsync instead for better performance.
+ * PowerPC S_UNLOCK use the gcc atomic routines.
*/
-#define S_UNLOCK(lock) \
-do \
-{ \
- __asm__ __volatile__ (" lwsync \n" ::: "memory"); \
- *((volatile slock_t *) (lock)) = 0; \
-} while (0)
+#define S_UNLOCK(lock) __sync_lock_release(lock)
#endif /* powerpc */
--
2.41.0
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-09-24 13:09 ` Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Heikki Linnakangas @ 2024-09-24 13:09 UTC (permalink / raw)
To: Srirama Kucherlapati <[email protected]>; Heikki Linnakangas <[email protected]>; Tom Lane <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Bruce Momjian <[email protected]>
On 24/09/2024 14:25, Srirama Kucherlapati wrote:
> Hi Heikki & team,
>
> Could you please let me know your comments on the previous details?
>
> Attached are the individual patches for AIX and gcc(__sync) routines.
Repeating what I said earlier:
> Ok, if we don't need the assembler code at all, that's good. A patch
> to introduce AIX support should not change it for non-AIX powerpc
> systems though. That might be a good change, but would need to be
> justified separately, e.g. by some performance testing, and should
> be a separate patch
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
@ 2024-09-25 06:04 ` Srirama Kucherlapati <[email protected]>
2024-10-04 15:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-09-25 06:04 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Bruce Momjian <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Tom Lane <[email protected]>
Hi Heikki,
As requested earlier, I need some assistance from the Postgres side to identify any tool or testcase to calibrate the sync routine performance in Postgres.
I see the below tools for benchmarking.
* Pgbench https://www.postgresql.org/docs/current/pgbench.html
* Pg_test_fsync https://www.postgresql.org/docs/current/pgtestfsync.html
* pg_test_timing https://www.postgresql.org/docs/current/pgtesttiming.html
Please let me know, if these tools are fine or else ca you suggest us with any additional tools to run the benchmarking.
> > Ok, if we don't need the assembler code at all, that's good. A patch to
> > introduce AIX support should not change it for non-AIX powerpc systems
> > though. That might be a good change, but would need to be justified
> > separately, e.g. by some performance testing, and should be a separate
> > patch.
> > If you make no changes to s_lock.h at all, will it work? Why not?
> With the existing asm code I see there are some syntax errors, being hit.
> But after reverting the old changes the issues resolved. Below are diffs.
> Let me know if I need to run any perf tools to check the performance of
> the __sync_lock_test_and_set change.
Thanks,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-10-04 15:04 ` Srirama Kucherlapati <[email protected]>
2024-11-25 16:26 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-10-04 15:04 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Bruce Momjian <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Tom Lane <[email protected]>
Hi Heikki and team,
A few updates…
> > Ok, if we don't need the assembler code at all, that's good. A patch to
> > introduce AIX support should not change it for non-AIX powerpc systems
> > though. That might be a good change, but would need to be justified
> > separately, e.g. by some performance testing, and should be a separate
> > patch.
We ran pgbench for both the patches on powerpc Linux and below are the test
results and both results are close.
PPCLE sync: is the patch with the spin lock using gcc __sync* routines.
PPCLE asm: is the patch with the assemble code.
>> pgbench -c 100 -p 5432 -d postgres -T 180 -r -P 10 -L 10 -j 20
OS/type : PPCLE sync PPCLE asm
---------------------------------------------------------
latency average : 136.257 138.552
---------------------------------------------------------
latency stddev : 234.74 238.603
---------------------------------------------------------
Initial
connection time : 101.791 88.411
---------------------------------------------------------
TPS(without initial
connection time) : 733.633924 721.440648
---------------------------------------------------------
No. of transactions
actually processed : 132080 129893
---------------------------------------------------------
No of transactions
above the 10.0 ms
latency limit : 124235/132080 122183/129893
(94.060%) (94.064%)
---------------------------------------------------------
Please let us know your comments.
BTW we are working on the other review comments as well.
Warm regards,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-10-04 15:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-11-25 16:26 ` Srirama Kucherlapati <[email protected]>
2024-11-25 21:02 ` Re: AIX support Robert Haas <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-11-25 16:26 UTC (permalink / raw)
To: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Bruce Momjian <[email protected]>; +Cc: Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Tom Lane <[email protected]>
Hi Team, here are few updates.
As of now we have removed all the old changes and made the changes that are
pretty much required by building from scratch. We had few issues with our
hardware as a result it took a while to build the code.
Below are the changes done as of now.
commit d2b4b4c2259e21ceaf05e393769b69728bfbee99 (HEAD -> master, origin/master, origin/HEAD)
>> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/backend/port/aix/mkldexport.sh
new file: src/include/port/aix.h
new file: src/makefiles/Makefile.aix
new file: src/template/aix
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: Makefile
modified: configure
modified: doc/src/sgml/dfunc.sgml
modified: src/Makefile.shlib
modified: src/backend/Makefile
modified: src/backend/port/aix/mkldexport.sh
modified: src/backend/utils/error/elog.c
modified: src/include/storage/s_lock.h
modified: src/port/strerror.c
modified: src/test/regress/expected/jsonb_jsonpath.out
We are seeing this one issue as of now with ‘gmake check’…
1 diff -U3 /home /postgres/src/test/regress/expected/jsonb_jsonpath.out /home/ /postgres/src/test/regress/results/jsonb_jsonpath.out
2 --- /home /postgres/src/test/regress/expected/jsonb_jsonpath.out 2024-10-22 02:30:00.545814423 -0500
3 +++ /home/ postgres/src/test/regress/results/jsonb_jsonpath.out 2024-11-12 03:31:52.251125056 -0600
4 @@ -2687,7 +2687,7 @@
5 select jsonb_path_query_tz('"12:34:56"', '$.time_tz().string()');
6 jsonb_path_query_tz
7 ---------------------
8 - "12:34:56-07:00"
9 + "12:34:56-08:00"
10 (1 row)
11
12 select jsonb_path_query('"12:34:56"', '$.time().string()');
After modifying the expected output for this testcase as below, the issue was
resolved and the test case passed. But we are trying to see the root cause of this.
"12:34:56-08:00"
We are working on the buildfarm setup to check the actual tests.
I shall keep you posted.
Warm regards,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* Re: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-10-04 15:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-11-25 16:26 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-11-25 21:02 ` Robert Haas <[email protected]>
2024-11-28 03:56 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Robert Haas @ 2024-11-25 21:02 UTC (permalink / raw)
To: Srirama Kucherlapati <[email protected]>; +Cc: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Bruce Momjian <[email protected]>; Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Tom Lane <[email protected]>
On Mon, Nov 25, 2024 at 11:27 AM Srirama Kucherlapati
<[email protected]> wrote:
> After modifying the expected output for this testcase as below, the issue was
> resolved and the test case passed. But we are trying to see the root cause of this.
>
> "12:34:56-08:00"
This is not an AIX-specific issue. It was fixed in commit
af21152268317323480caa790c4a6347110f8085, committed October 30th.
--
Robert Haas
EDB: http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-10-04 15:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-11-25 16:26 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-11-25 21:02 ` Re: AIX support Robert Haas <[email protected]>
@ 2024-11-28 03:56 ` Srirama Kucherlapati <[email protected]>
2024-12-04 09:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
0 siblings, 1 reply; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-11-28 03:56 UTC (permalink / raw)
To: Robert Haas <[email protected]>; +Cc: Heikki Linnakangas <[email protected]>; Heikki Linnakangas <[email protected]>; Bruce Momjian <[email protected]>; Peter Eisentraut <[email protected]>; Alvaro Herrera <[email protected]>; pgsql-hackers; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>; Tom Lane <[email protected]>
>> This is not an AIX-specific issue. It was fixed in commit
>> af21152268317323480caa790c4a6347110f8085, committed October 30th.
Thanks Robert, it worked after applying this change.
Warm regards,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
* RE: AIX support
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-13 11:49 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Re: AIX support Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-10-04 15:04 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-11-25 16:26 ` RE: AIX support Srirama Kucherlapati <[email protected]>
2024-11-25 21:02 ` Re: AIX support Robert Haas <[email protected]>
2024-11-28 03:56 ` RE: AIX support Srirama Kucherlapati <[email protected]>
@ 2024-12-04 09:57 ` Srirama Kucherlapati <[email protected]>
0 siblings, 0 replies; 20+ messages in thread
From: Srirama Kucherlapati @ 2024-12-04 09:57 UTC (permalink / raw)
To: pgsql-hackers; [email protected] <[email protected]>; +Cc: Heikki Linnakangas <[email protected]>; Bruce Momjian <[email protected]>; Robert Haas <[email protected]>; Peter Eisentraut <[email protected]>; Heikki Linnakangas <[email protected]>; Alvaro Herrera <[email protected]>; Laurenz Albe <[email protected]>; Noah Misch <[email protected]>; Michael Paquier <[email protected]>; Andres Freund <[email protected]>; Thomas Munro <[email protected]>; [email protected] <[email protected]>; Tom Lane <[email protected]>
Hi Team, few more updates on the buildfarm, all the tests have passed and below
is the gist of the logs. We are working on the cleaning up the changes and will
post them for review.
Tue Dec 3 04:08:29 2024: buildfarm run for CHANGEME:HEAD starting
CHANGEME:HEAD [04:09:49] running build ...
======== make log ===========
CHANGEME:HEAD [04:09:54] running basic regression tests ...
======== make check logs ===========
CHANGEME:HEAD [04:19:47] running make contrib ...
======== make contrib log ===========
CHANGEME:HEAD [04:19:48] running make testmodules ...
======== make testmodules log ===========
CHANGEME:HEAD [04:19:49] running install ...
======== make install log ===========
CHANGEME:HEAD [04:20:51] running make contrib install ...
======== make contrib install log ===========
CHANGEME:HEAD [04:21:20] running testmodules install ...
======== testmodules install log ===========
CHANGEME:HEAD [04:21:33] checking pg_upgrade
======== pg_upgrade check log ===========
CHANGEME:HEAD [04:21:33] checking test-decoding
======== test-decoding check log ===========
========================== output_iso/log/initdb.log ================
========================== output_iso/log/postmaster.log ================
========================== test_decoding/log/initdb.log ================
========================== test_decoding/log/postmaster.log ================
CHANGEME:HEAD [04:23:40] running make check miscellaneous modules ...
=========== Module commit_ts check =============
=========== Module injection_points check =============
=========== Module test_oat_hooks check =============
=========== Module test_slru check =============
=========== Module unsafe_tests check =============
=========== Module basic_archive check =============
=========== Module pg_freespacemap check =============
=========== Module pg_logicalinspect check =============
=========== Module pg_stat_statements check =============
=========== Module pg_walinspect check =============
=========== Module test_decoding check =============
CHANGEME:HEAD [04:31:54] setting up db cluster (C)...
======== initdb log (C) ===========
CHANGEME:HEAD [04:32:13] starting db (C)...
======== start db (C) : 1 log ========
=========== db log file ==========
CHANGEME:HEAD [04:32:14] running installcheck (C)...
======== make installcheck log ===========
CHANGEME:HEAD [04:44:14] restarting db (C)...
======== stop db (C): 1 log ==========
=========== db log file ==========
======== start db (C) : 2 log ========
=========== db log file ==========
CHANGEME:HEAD [04:44:16] running make isolation check ...
======== make isolation check logs ===========
CHANGEME:HEAD [04:48:22] restarting db (C)...
======== stop db (C): 2 log ==========
=========== db log file ==========
======== start db (C) : 3 log ========
=========== db log file ==========
CHANGEME:HEAD [04:49:24] running make PL installcheck (C)...
======== make pl installcheck log ===========
CHANGEME:HEAD [04:49:44] restarting db (C)...
======== stop db (C): 3 log ==========
=========== db log file ==========
======== start db (C) : 4 log ========
=========== db log file ==========
CHANGEME:HEAD [04:49:47] running make contrib installcheck (C)...
======== make contrib installcheck log ===========
CHANGEME:HEAD [04:55:01] restarting db (C)...
======== stop db (C): 4 log ==========
=========== db log file ==========
======== start db (C) : 5 log ========
=========== db log file ==========
CHANGEME:HEAD [04:55:09] running make test-modules installcheck (C)...
======== make testmodules installcheck log ===========
CHANGEME:HEAD [04:56:54] stopping db (C)...
======== stop db (C): 5 log ==========
=========== db log file ==========
CHANGEME:HEAD [04:56:57] running make ecpg check ...
======== make ecpg check logs ===========
CHANGEME:HEAD [04:58:38] OK
======== log passed to send_result ===========
======== log passed to send_result ===========
All stages succeeded
Generated logs files
aixpg-lpar01:~/build-farm-17/buildroot/HEAD/CHANGEME.fromsource-logs]
>> ls
build.log pl-install-check-C.log
check-pg_upgrade.log startdb-C-1.log
check.log startdb-C-2.log
configure.log startdb-C-3.log
contrib-install-check-C.log startdb-C-4.log
ecpg-check.log startdb-C-5.log
initdb-C.log stopdb-C-1.log
install-check-C.log stopdb-C-2.log
install-contrib.log stopdb-C-3.log
install-testmodules.log stopdb-C-4.log
isolation-check.log stopdb-C-5.log
make-contrib.log test-decoding-check.log
make-install.log testmodules-install-check-C.log
make-testmodules.log web-txn.data
misc-check.log
Warm regards,
Sriram.
^ permalink raw reply [nested|flat] 20+ messages in thread
end of thread, other threads:[~2024-12-04 09:57 UTC | newest]
Thread overview: 20+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-06-19 15:15 Re: AIX support Heikki Linnakangas <[email protected]>
2024-06-19 15:57 ` Srirama Kucherlapati <[email protected]>
2024-06-21 17:00 ` Srirama Kucherlapati <[email protected]>
2024-08-14 03:31 ` Srirama Kucherlapati <[email protected]>
2024-08-14 07:46 ` Heikki Linnakangas <[email protected]>
2024-08-14 15:22 ` Srirama Kucherlapati <[email protected]>
2024-08-14 20:09 ` Heikki Linnakangas <[email protected]>
2024-09-11 12:38 ` Srirama Kucherlapati <[email protected]>
2024-09-11 21:57 ` Heikki Linnakangas <[email protected]>
2024-09-11 22:06 ` Thomas Munro <[email protected]>
2024-09-13 11:49 ` Srirama Kucherlapati <[email protected]>
2024-09-17 16:29 ` Srirama Kucherlapati <[email protected]>
2024-09-24 11:25 ` Srirama Kucherlapati <[email protected]>
2024-09-24 13:09 ` Heikki Linnakangas <[email protected]>
2024-09-25 06:04 ` Srirama Kucherlapati <[email protected]>
2024-10-04 15:04 ` Srirama Kucherlapati <[email protected]>
2024-11-25 16:26 ` Srirama Kucherlapati <[email protected]>
2024-11-25 21:02 ` Robert Haas <[email protected]>
2024-11-28 03:56 ` Srirama Kucherlapati <[email protected]>
2024-12-04 09:57 ` Srirama Kucherlapati <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox