aerospike / php-client

Aerospike Client for PHP 8
https://aerospike.github.io/php-client/
9 stars 2 forks source link

Build failure with 0.2.0 on aarch64 #9

Closed thias closed 10 months ago

thias commented 10 months ago

Hi,

I've updated our x86_64 build to 0.2.0 with no issues, but when trying to rebuild for aarch64, I got the following failure:

   [...]
   Compiling ext-php-rs v0.10.3
   Compiling aerospike-sync v0.1.0 (https://github.com/aerospike/aerospike-client-rust.git?branch=php-rs#56a13d54)
error[E0308]: mismatched types
   --> /builddir/build/BUILD/php-client-0.2.0-vendor/vendor/ext-php-rs/src/types/object.rs:149:17
    |
147 |             let res = zend_hash_str_find_ptr_lc(
    |                       ------------------------- arguments to this function are incorrect
148 |                 &(*self.ce).function_table,
149 |                 name.as_ptr() as *const i8,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: function defined here
   --> /builddir/build/BUILD/php-client-0.2.0-vendor/NTS/target/debug/build/ext-php-rs-522d80dcff97b12d/out/bindings.rs:3:12213
    |
3   | ...estroy (ht : * mut HashTable) ; } extern "C" { pub fn zend_hash_str_find_ptr_lc (ht : * const HashTable , str_ : * const :: std :: os ...
    |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> /builddir/build/BUILD/php-client-0.2.0-vendor/vendor/ext-php-rs/src/zend/function.rs:55:47
   |
55 |             let res = zend_fetch_function_str(name.as_ptr() as *const i8, name.len());
   |                       ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
   |                       |
   |                       arguments to this function are incorrect
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  --> /builddir/build/BUILD/php-client-0.2.0-vendor/NTS/target/debug/build/ext-php-rs-522d80dcff97b12d/out/bindings.rs:3:41473
   |
3  | ...val , pub prev : zend_vm_stack , } extern "C" { pub fn zend_fetch_function_str (name : * const :: std :: os :: raw :: c_char , len : u...
   |                                                           ^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
  --> /builddir/build/BUILD/php-client-0.2.0-vendor/vendor/ext-php-rs/src/zend/function.rs:68:21
   |
66 |                 let res = zend_hash_str_find_ptr_lc(
   |                           ------------------------- arguments to this function are incorrect
67 |                     &ce.function_table,
68 |                     name.as_ptr() as *const i8,
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
   |
   = note: expected raw pointer `*const u8`
              found raw pointer `*const i8`
note: function defined here
  --> /builddir/build/BUILD/php-client-0.2.0-vendor/NTS/target/debug/build/ext-php-rs-522d80dcff97b12d/out/bindings.rs:3:12213
   |
3  | ...estroy (ht : * mut HashTable) ; } extern "C" { pub fn zend_hash_str_find_ptr_lc (ht : * const HashTable , str_ : * const :: std :: os ...
   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.

I just tried recompiling 0.1.0 and it worked:

   [...]
   Compiling ext-php-rs v0.10.1
   Compiling aerospike-sync v0.1.0 (https://github.com/aerospike/aerospike-client-rust.git?branch=php-rs#787140a1)
   Compiling aerospike v0.1.0 (/builddir/build/BUILD/php-client-e37a8a1c404f516d5261da5cb8c7108b79561a4e-vendor/NTS)
warning: unused import: `std::collections::BTreeMap`
  --> src/lib.rs:22:5
[...]
warning: `aerospike` (lib) generated 17 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 3m 43s

It does look like it could be related to the newer ext-php-rs, though. This is with PHP 8.1.24 on Red Hat Enterprise Linux 9.

ptondereau commented 10 months ago

Hello, can you tell us what version of PHP you've used?

thias commented 10 months ago

This is with the latest PHP 8.1, 8.1.25 (original report was with 8.1.24, but I've since re-tried a few times and the latest was with 8.1.25).

ptondereau commented 10 months ago

I forgot to ask what is the command line you've used to build the project sorry

thias commented 10 months ago

I'm building for an rpm package which is found here: https://github.com/exogroup/rpms/blob/master/php-aerospike/php-aerospike.spec This is the relevant part of the spec file:

%build
%{?dtsenable}
export CFLAGS="%{optflags}"

cd NTS
PHP_CONFIG=%{_bindir}/%{?scl_prefix}php-config cargo build

And this is what it actually translates to when building:

Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.ctwvbn
+ umask 022
+ cd /builddir/build/BUILD
+ cd php-client-0.2.0-vendor
+ export 'CFLAGS=-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -fasynchronous-unwind-tables -fstack-clash-protection'
+ CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -fasynchronous-unwind-tables -fstack-clash-protection'
+ cd NTS
+ PHP_CONFIG=/usr/bin/php-config
+ cargo build
   Compiling libc v0.2.150
   Compiling proc-macro2 v1.0.69
   Compiling unicode-ident v1.0.12
   Compiling version_check v0.9.4
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
[... all the way to the error reported ...]
thias commented 10 months ago

FYI, I have just retried a build without the Red Hat provided CFLAGS, but get the exact same errors.

vmsachin commented 10 months ago

Hi @thias, there seems to be some issue with the underlying extension but I have made a hard dependency on a prior version of the ext-php-rs(0.10.1) and our client works as expected with that version of the ext-php-rs. You can test it with that. Once the fix is in for 0.10.3 version of the ext-php-rs we will bump the version with our release.

thias commented 10 months ago

Thanks! If I had known the syntax to pin a specific version was just adding an = sign, I would have tried that already. Building with 0.10.1 works around the issue for now indeed.

vmsachin commented 10 months ago

@thias glad it worked 👍 I'll go ahead and close this issue but will keep in mind when we bump version to the latest ext-php-rs version.

thias commented 10 months ago

This has now been fixed upstream in https://github.com/davidcole1340/ext-php-rs/pull/280 and released in 0.10.4. I can confirm that the Aerospike PHP Client 0.2.0 now builds fine again on aarch64 with it, and the pin to 0.10.1 is no longer required.