davidcole1340 / ext-php-rs

Bindings for the Zend API to build PHP extensions natively in Rust.
Apache License 2.0
598 stars 64 forks source link

Build failure with 0.10.3 on aarch64 #279

Closed thias closed 11 months ago

thias commented 11 months ago

I've bumped into a build issue with Aerospike's early alpha module. It's happening on aarch64 only, x86_64 builds fine. It used to build fine for both archs with php-rs version earlier than 0.10.3.

https://github.com/aerospike/php-client/issues/9

I'm pasting the same output from the ticket above here:

   [...]
   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`.

Searching for the error, I came across https://users.rust-lang.org/t/expected-const-i8-found-const-u8-for-c-function-pointer-waiting-for-a-const-char/2441 which mentions that std::ffi::CString could be the correct structure to us for cases like this.

thias commented 11 months ago

It seems to me that the issue might have been introduced in 064ef747c1988d2749d346ac3ec7b8ea1b962536 by @danog.

danog commented 11 months ago

Should be all good now!

thias commented 11 months ago

It built fine now, thanks a lot!