public inbox for [email protected]
help / color / mirror / Atom feedFrom: Srirama Kucherlapati <[email protected]>
To: Peter Eisentraut <[email protected]>
To: [email protected] <[email protected]>
To: Heikki Linnakangas <[email protected]>
Cc: Tristan Partin <[email protected]>
Cc: AIX PG user <[email protected]>
Subject: RE: AIX support
Date: Fri, 19 Dec 2025 15:34:31 +0000
Message-ID: <SJ4PPFB817783267BD66F22BFC328D93F81DBA8A@SJ4PPFB81778326.namprd15.prod.outlook.com> (raw)
In-Reply-To: <[email protected]>
References: <CY5PR11MB63928CC05906F27FB10D74D0FD322@CY5PR11MB6392.namprd11.prod.outlook.com>
<[email protected]>
<176279401378.2081919.12877701948713975661.pgcf@coridan.postgresql.org>
<SJ4PPFB817783263EA0FD91EBC346308C51DBA3A@SJ4PPFB81778326.namprd15.prod.outlook.com>
<[email protected]>
Hi Peter/Heikki/Tristan
Please find the attached changes for the below comments. Along with comments from Tristan.
Please let me know if these meson specific changes are fine.
0001-Support-for-AIX-meson-updates.pg19.patch - has the changes for the below comments only.
0001-Support-for-AIX-all-meson.pg19.patch - has all the meson specific changes.
>> 1) In meson.build:
>> + cppflags += '-D_GNU_SOURCE’
>> I don't think this symbol is applicable to AIX.
AIX provides certain functions similar to Linux, but with different names and
signatures. To align them with Linux behaviour, the GNU_SOURCE macro is defined,
which enables AIX functions to behave like their Linux counterparts.
You are right, this is not needed for AIX. I have removed and everything got build.
>> 2) In meson.build:
>> + # Native memset() is faster, tested on:
>> + memset_loop_limit = 0
>> The comment sentence appears to be truncated.
For now, removed this, I’ll provide statistics in a different thread as Heikki suggested.
>> 3) In meson.build:
>> +#if cc.alignment('int64_t', args: test_c_args, prefix: ‘#include
>> <stdint.h>') > alignof_double
>>+# error('alignment of int64_t is greater than the alignment of double’)
>> +#endif
>> This commented out code cannot be left like this. Either remove it or
>> adjust it as required.
I have updated the similar logic as in regular GNU configure file.
>> 4) In meson.build:
>> /* This must match the corresponding code in c.h: */
>> - #if defined(__GNUC__)
>> + #if defined(__GNUC__) || defined(__IBMC__)
>> You code does not observe what the comment says.
You are right, I have removed this as this is relevant only if we are compiling with XLC. Right now, its compiled with gcc
>> 5) The changes in src/include/port/aix.h are nonsense. This was
>> previously pointed out and you said you would address this.
The changes are irrelevant now, removed them. As all these additional definitions are covered by the postgres defined header file (src/include/utils/float.h). We can use “_H_FLOAT” to skip the system header "float.h”.
I’d like to finalize all Meson-specific changes first. Meanwhile, I’m also working on the other comments.
Kindly let me know your thoughts and feedback on the changes.
Thanks,
Sriram.
Attachments:
[application/octet-stream] 0001-Support-for-AIX-all-meson.pg19.patch (8.1K, 3-0001-Support-for-AIX-all-meson.pg19.patch)
download | inline diff:
diff --git a/meson.build b/meson.build
index 6e7ddd74683..6ba24187d15 100644
--- a/meson.build
+++ b/meson.build
@@ -206,6 +206,26 @@ if host_system == 'cygwin'
mod_link_with_name = 'lib@[email protected]'
mod_link_with_dir = 'libdir'
+elif host_system == 'aix'
+ sema_kind = 'unnamed_posix'
+ 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]'
+ dl_suffix = '.a'
+ # This flag is required to make sure the user spefic float.h is
+ # picked instead of the system float.h header file, which doesnot
+ # have definition like float8, etc
+ cflags += '-D_H_FLOAT'
+
+ # 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'
+
+
elif host_system == 'darwin'
dlsuffix = '.dylib'
library_path_var = 'DYLD_LIBRARY_PATH'
@@ -1765,10 +1785,49 @@ endforeach
# 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('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double
- error('alignment of int64_t is greater than the alignment of double')
-endif
+if host_system != 'aix'
+ alignof_double = cdata.get('ALIGNOF_DOUBLE')
+ if cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double
+ error('alignment of int64_t is greater than the alignment of double')
+ endif
+else
+ # The AIX 'power' alignment rules apply the natural alignment of the "first
+ # member" if it is of a floating-point data type (or is an aggregate whose
+ # recursively "first" member or element is such a type). The alignment
+ # associated with these types for subsequent members use an alignment value
+ # where the floating-point data type is considered to have 4-byte alignment.
+ # More info
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99557
+ #
+ # The double is aligned to 4-bytes on AIX in aggregates. But to maintain
+ # alignement across platforms the max alignment of long should be considered.
+
+ # Get the alignment values
+ ac_cv_alignof_long = cc.alignment('long', args: test_c_args, prefix: '#include <stdint.h>')
+ ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include <stdint.h>')
+ ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>')
+
+ message('Alignment of long : @0@'.format(ac_cv_alignof_long))
+ message('Alignment of double : @0@'.format(ac_cv_alignof_double))
+ message('Alignment of int64_t : @0@'.format(ac_cv_alignof_int64_t))
+
+ # Start with long
+ alignof_double = ac_cv_alignof_long
+ message('MAX ALIGN ac_cv_alignof_long')
+
+ # Compare with double
+ if alignof_double < ac_cv_alignof_double
+ alignof_double = ac_cv_alignof_double
+ message('MAX ALIGN ac_cv_alignof_double')
+ endif
+
+ # Compare with int64_t
+ if alignof_double < ac_cv_alignof_int64_t
+ alignof_double = ac_cv_alignof_int64_t
+ message('MAX ALIGN ac_cv_alignof_int64_t')
+ endif
+endif
+message('MAX ALIGN OF DOUBLE : @0@'.format(alignof_double))
cdata.set('MAXIMUM_ALIGNOF', alignof_double)
cdata.set('SIZEOF_LONG', cc.sizeof('long', args: test_c_args))
@@ -3466,13 +3525,17 @@ endif
installed_targets = [
backend_targets,
bin_targets,
- libpq_st,
pl_targets,
contrib_targets,
nls_mo_targets,
ecpg_targets,
]
+# The static libpq is skipped in AIX. This is not required.
+if host_system != 'aix'
+ installed_targets += [libpq_st]
+endif
+
if oauth_flow_supported
installed_targets += [
libpq_oauth_so,
@@ -3816,7 +3879,13 @@ add_test_setup('running',
###############################################################
alias_target('backend', backend_targets)
-alias_target('bin', bin_targets + [libpq_st])
+if host_system != 'aix'
+ alias_target('bin', bin_targets + [libpq_st])
+else
+ # The static libpq is skipped in AIX. This is not required.
+ alias_target('bin', bin_targets)
+endif
+
alias_target('pl', pl_targets)
alias_target('contrib', contrib_targets)
alias_target('testprep', testprep_targets)
diff --git a/src/backend/meson.build b/src/backend/meson.build
index b831a541652..4838f245ab3 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -125,6 +125,24 @@ if host_system == 'windows'
'--FILEDESC', 'PostgreSQL Server',])
endif
+if 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
+
+
postgres = executable('postgres',
backend_input,
sources: post_export_backend_sources,
diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build
index 56e0a21651b..af96e375a9b 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -16,6 +16,7 @@ if host_system == 'windows'
endif
# see src/interfaces/libpq/meson.build
+if host_system != 'aix'
ecpg_compat_st = static_library('libecpg_compat',
ecpg_compat_sources,
include_directories: ecpg_compat_inc,
@@ -25,6 +26,7 @@ ecpg_compat_st = static_library('libecpg_compat',
kwargs: default_lib_args,
)
ecpg_targets += ecpg_compat_st
+endif
ecpg_compat_so = shared_library('libecpg_compat',
ecpg_compat_sources + ecpg_compat_so_sources,
diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build
index 8f478c6a73e..7d28cd67388 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -25,6 +25,7 @@ if host_system == 'windows'
endif
# see src/interfaces/libpq/meson.build
+if host_system != 'aix'
ecpglib_st = static_library('libecpg',
ecpglib_sources,
include_directories: ecpglib_inc,
@@ -35,6 +36,7 @@ ecpglib_st = static_library('libecpg',
kwargs: default_lib_args,
)
ecpg_targets += ecpglib_st
+endif
ecpglib_so = shared_library('libecpg',
ecpglib_sources + ecpglib_so_sources,
diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build
index 02301ec9acb..97f4e1c6eda 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -21,6 +21,7 @@ if host_system == 'windows'
endif
# see src/interfaces/libpq/meson.build
+if host_system != 'aix'
ecpg_pgtypes_st = static_library('libpgtypes',
ecpg_pgtypes_sources,
include_directories: ecpg_pgtypes_inc,
@@ -30,6 +31,7 @@ ecpg_pgtypes_st = static_library('libpgtypes',
kwargs: default_lib_args,
)
ecpg_targets += ecpg_pgtypes_st
+endif
ecpg_pgtypes_so = shared_library('libpgtypes',
ecpg_pgtypes_sources + ecpg_pgtypes_so_sources,
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index a74e885b169..98ced9376d9 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -57,6 +57,7 @@ libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH']
# 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).
+if host_system != 'aix'
libpq_st = static_library('libpq',
libpq_sources,
include_directories: [libpq_inc],
@@ -65,6 +66,7 @@ libpq_st = static_library('libpq',
dependencies: [frontend_stlib_code, libpq_deps],
kwargs: default_lib_args,
)
+endif
libpq_so = shared_library('libpq',
libpq_sources + libpq_so_sources,
[application/octet-stream] 0001-Support-for-AIX-meson-updates.pg19.patch (8.9K, 4-0001-Support-for-AIX-meson-updates.pg19.patch)
download | inline diff:
diff --git a/meson.build b/meson.build
index 304a9184075..6ba24187d15 100644
--- a/meson.build
+++ b/meson.build
@@ -215,15 +215,16 @@ elif host_system == 'aix'
mod_link_with_dir = 'libdir'
mod_link_with_name = '@[email protected]'
dl_suffix = '.a'
- cppflags += '-D_GNU_SOURCE'
+ # This flag is required to make sure the user spefic float.h is
+ # picked instead of the system float.h header file, which doesnot
+ # have definition like float8, etc
+ cflags += '-D_H_FLOAT'
# 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:
- memset_loop_limit = 0
elif host_system == 'darwin'
dlsuffix = '.dylib'
@@ -1784,10 +1785,49 @@ endforeach
# 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('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double
-# error('alignment of int64_t is greater than the alignment of double')
-#endif
+if host_system != 'aix'
+ alignof_double = cdata.get('ALIGNOF_DOUBLE')
+ if cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double
+ error('alignment of int64_t is greater than the alignment of double')
+ endif
+else
+ # The AIX 'power' alignment rules apply the natural alignment of the "first
+ # member" if it is of a floating-point data type (or is an aggregate whose
+ # recursively "first" member or element is such a type). The alignment
+ # associated with these types for subsequent members use an alignment value
+ # where the floating-point data type is considered to have 4-byte alignment.
+ # More info
+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99557
+ #
+ # The double is aligned to 4-bytes on AIX in aggregates. But to maintain
+ # alignement across platforms the max alignment of long should be considered.
+
+ # Get the alignment values
+ ac_cv_alignof_long = cc.alignment('long', args: test_c_args, prefix: '#include <stdint.h>')
+ ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include <stdint.h>')
+ ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>')
+
+ message('Alignment of long : @0@'.format(ac_cv_alignof_long))
+ message('Alignment of double : @0@'.format(ac_cv_alignof_double))
+ message('Alignment of int64_t : @0@'.format(ac_cv_alignof_int64_t))
+
+ # Start with long
+ alignof_double = ac_cv_alignof_long
+ message('MAX ALIGN ac_cv_alignof_long')
+
+ # Compare with double
+ if alignof_double < ac_cv_alignof_double
+ alignof_double = ac_cv_alignof_double
+ message('MAX ALIGN ac_cv_alignof_double')
+ endif
+
+ # Compare with int64_t
+ if alignof_double < ac_cv_alignof_int64_t
+ alignof_double = ac_cv_alignof_int64_t
+ message('MAX ALIGN ac_cv_alignof_int64_t')
+ endif
+endif
+message('MAX ALIGN OF DOUBLE : @0@'.format(alignof_double))
cdata.set('MAXIMUM_ALIGNOF', alignof_double)
cdata.set('SIZEOF_LONG', cc.sizeof('long', args: test_c_args))
@@ -1839,7 +1879,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(__IBMC__)
+ #if defined(__GNUC__)
#define pg_attribute_aligned(a) __attribute__((aligned(a)))
#elif defined(_MSC_VER)
#define pg_attribute_aligned(a) __declspec(align(a))
@@ -3485,13 +3525,17 @@ endif
installed_targets = [
backend_targets,
bin_targets,
- libpq_st,
pl_targets,
contrib_targets,
nls_mo_targets,
ecpg_targets,
]
+# The static libpq is skipped in AIX. This is not required.
+if host_system != 'aix'
+ installed_targets += [libpq_st]
+endif
+
if oauth_flow_supported
installed_targets += [
libpq_oauth_so,
@@ -3835,7 +3879,13 @@ add_test_setup('running',
###############################################################
alias_target('backend', backend_targets)
-alias_target('bin', bin_targets + [libpq_st])
+if host_system != 'aix'
+ alias_target('bin', bin_targets + [libpq_st])
+else
+ # The static libpq is skipped in AIX. This is not required.
+ alias_target('bin', bin_targets)
+endif
+
alias_target('pl', pl_targets)
alias_target('contrib', contrib_targets)
alias_target('testprep', testprep_targets)
diff --git a/src/include/port/aix.h b/src/include/port/aix.h
index dd7cfb197cd..c86983a4452 100644
--- a/src/include/port/aix.h
+++ b/src/include/port/aix.h
@@ -1,26 +1,3 @@
/*
* src/include/port/aix.h
*/
-
-/* This change is required for the meson changes as the autoconf is not run and
- * to resolve the conflicts in picking the float.h details by default from the
- * postgres defined datatypes.
- */
-#ifdef _AIX
-#ifndef PGDLLIMPORT
-#define PGDLLIMPORT
-#endif /* PGDLLIMPORT */
-typedef float float4;
-typedef double float8;
-
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
-#define pg_noreturn _Noreturn
-#elif defined(__GNUC__)
-#define pg_noreturn __attribute__((noreturn))
-#else
-#define pg_noreturn
-#endif
-
-#include <stdbool.h>
-
-#endif /*_AIX */
diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build
index 3f39187cdcc..af96e375a9b 100644
--- a/src/interfaces/ecpg/compatlib/meson.build
+++ b/src/interfaces/ecpg/compatlib/meson.build
@@ -16,7 +16,8 @@ if host_system == 'windows'
endif
# see src/interfaces/libpq/meson.build
-ecpg_compat_st = static_library('libecpg_compat_static',
+if host_system != 'aix'
+ecpg_compat_st = static_library('libecpg_compat',
ecpg_compat_sources,
include_directories: ecpg_compat_inc,
c_args: ecpg_compat_c_args,
@@ -25,6 +26,7 @@ ecpg_compat_st = static_library('libecpg_compat_static',
kwargs: default_lib_args,
)
ecpg_targets += ecpg_compat_st
+endif
ecpg_compat_so = shared_library('libecpg_compat',
ecpg_compat_sources + ecpg_compat_so_sources,
diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build
index e9faf290a2b..7d28cd67388 100644
--- a/src/interfaces/ecpg/ecpglib/meson.build
+++ b/src/interfaces/ecpg/ecpglib/meson.build
@@ -25,7 +25,8 @@ if host_system == 'windows'
endif
# see src/interfaces/libpq/meson.build
-ecpglib_st = static_library('libecpg_static',
+if host_system != 'aix'
+ecpglib_st = static_library('libecpg',
ecpglib_sources,
include_directories: ecpglib_inc,
c_args: ecpglib_c_args,
@@ -35,6 +36,7 @@ ecpglib_st = static_library('libecpg_static',
kwargs: default_lib_args,
)
ecpg_targets += ecpglib_st
+endif
ecpglib_so = shared_library('libecpg',
ecpglib_sources + ecpglib_so_sources,
diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build
index 94d1d0ad1ef..97f4e1c6eda 100644
--- a/src/interfaces/ecpg/pgtypeslib/meson.build
+++ b/src/interfaces/ecpg/pgtypeslib/meson.build
@@ -21,7 +21,8 @@ if host_system == 'windows'
endif
# see src/interfaces/libpq/meson.build
-ecpg_pgtypes_st = static_library('libpgtypes_static',
+if host_system != 'aix'
+ecpg_pgtypes_st = static_library('libpgtypes',
ecpg_pgtypes_sources,
include_directories: ecpg_pgtypes_inc,
c_args: ecpg_pgtypes_c_args,
@@ -30,6 +31,7 @@ ecpg_pgtypes_st = static_library('libpgtypes_static',
kwargs: default_lib_args,
)
ecpg_targets += ecpg_pgtypes_st
+endif
ecpg_pgtypes_so = shared_library('libpgtypes',
ecpg_pgtypes_sources + ecpg_pgtypes_so_sources,
diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build
index eea175ad14a..98ced9376d9 100644
--- a/src/interfaces/libpq/meson.build
+++ b/src/interfaces/libpq/meson.build
@@ -57,7 +57,8 @@ libpq_so_c_args = ['-DUSE_DYNAMIC_OAUTH']
# 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).
-libpq_st = static_library('libpq_static',
+if host_system != 'aix'
+libpq_st = static_library('libpq',
libpq_sources,
include_directories: [libpq_inc],
c_args: libpq_c_args,
@@ -65,6 +66,7 @@ libpq_st = static_library('libpq_static',
dependencies: [frontend_stlib_code, libpq_deps],
kwargs: default_lib_args,
)
+endif
libpq_so = shared_library('libpq',
libpq_sources + libpq_so_sources,
diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl
index 25827c42a68..19c8b60560f 100644
--- a/src/tools/gen_export.pl
+++ b/src/tools/gen_export.pl
@@ -21,7 +21,7 @@ if (not( $format eq 'darwin'
or $format eq 'win'
or $format eq 'aix'))
{
- die "$0: $format is not yet handled (only darwin, gnu, win are)\n";
+ die "$0: $format is not yet handled (only darwin, gnu, win, aix are)\n";
}
open(my $input_handle, '<', $input)
view thread (73+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: RE: AIX support
In-Reply-To: <SJ4PPFB817783267BD66F22BFC328D93F81DBA8A@SJ4PPFB81778326.namprd15.prod.outlook.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox