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 = '@0@.imp' 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 ') > 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 ') > 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 ') + ac_cv_alignof_double = cc.alignment('double', args: test_c_args, prefix: '#include ') + ac_cv_alignof_int64_t = cc.alignment('int64_t', args: test_c_args, prefix: '#include ') + + 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 - -#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)