aerospike-community / aerospike-client-php

Aerospike client for PHP7
Apache License 2.0
29 stars 28 forks source link

Build failure with aerospike-client-c 5.x #65

Closed thias closed 3 years ago

thias commented 3 years ago

I've been preparing our PHP 7.3 environment to work with Aerospike, and I've encountered the following error:

libtool: compile:  cc -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -I/builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS -DPHP_ATOM_INC -I/builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS/include -I/builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS/main -I/builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -std=gnu99 -c /builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS/client/predicate.c  -fPIC -DPIC -o client/.libs/predicate.o
/builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS/client/php_client_utils.c: In function 'set_policy_defaults_from_ini':
/builddir/build/BUILD/aerospike-client-php-f6931abc8826e48df71cf9c778bd5657ada13b41/NTS/client/php_client_utils.c:96:24: error: 'as_policy_apply' has no member named 'gen'
  config->policies.apply.gen = (as_policy_gen)int_ini_value;
                        ^
make: *** [client/php_client_utils.lo] Error 1
make: *** Waiting for unfinished jobs....

Looking at https://www.aerospike.com/download/client/c/notes.html#5.0.0 I was able to find:

Remove "as_policy_apply.gen" and "as_policy_apply.gen_value" because the server does not support these fields in UDF calls. The read-modify-write usage model can still be enforced inside the UDF code itself.

I'm using the latest versions of everything I could find, which includes the aerospike-client-c 5.1.0. I'll now try with 4.6.x, but maybe this should be fixed/updated in the php client module?

dwelch-spike commented 3 years ago

Hi @thias,

The PHP client currently uses C client 4.6.5. So, for now, try using that.

thias commented 3 years ago

Thanks @dwelch-spike, that mostly worked indeed. Compilation completed, but now I get the following error while checking a trivial load of the module:

$ php --define extension=modules/aerospike.so --modules | grep aero
PHP Warning:  PHP Startup: Unable to load dynamic library 'modules/aerospike.so' (tried: modules/aerospike.so (modules/aerospike.so: undefined symbol: g_as_log), /usr/lib64/php/modules/modules/aerospike.so.so (/usr/lib64/php/modules/modules/aerospike.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

The relevant bit being modules/aerospike.so: undefined symbol: g_as_log

It's the same message someone already reported in https://github.com/aerospike/aerospike-client-python/issues/119 but that doesn't give me much indication about what could be the actual problem.

I'm using a custom compat-aerospike-client-c-4.6.20-1.el7_9 rpm package built by myself, that includes the latest "common", "mod-lua" and "luajit" (the git modules for those in 4.6.20 don't specify any tag or commit), and compiled using make EVENT_LIB=libev USE_LUAJIT=1 on RHEL7 with libev 4.15.7. Given g_as_log seems to be part of the "common" codebase, there must be some linking issue somewhere. I've forced the PHP modules to use the static libaerospike.a with the same result, so the problem must be with aerospike-client-c... here I go down the rabbit hole.

thias commented 3 years ago

The issue was on my end: I'm too used to phpize/configure/make taking care of everything, and hadn't properly replicated all of the required CFLAGS and LDFLAGS overrides from build.sh. The build could benefit a lot from an updated config.m4 and from libaerospike using something like pkg-config... but that's another issue.