Skip to content

Compilation fails with PHP 8.4 (embed + ZTS) #718

@4RSIM3R

Description

@4RSIM3R

Code of Conduct

Description

Compilation fails with PHP 8.4 (embed + ZTS)

Description

ext-php-rs fails to compile against PHP 8.4.11 built with --enable-embed=shared --enable-zts. Several struct fields and enum constants have been renamed or removed in PHP 8.4's C headers, causing 4 compilation errors.

Tested on both 0.15.8 from crates.io and latest main branch (444d62a5).

Environment

  • ext-php-rs version: 0.15.8 (also tested git main @ 444d62a)
  • PHP version: 8.4.11
  • PHP configure flags: --enable-embed=shared --enable-zts --disable-zend-signals
  • OS: macOS 14.4 (aarch64-apple-darwin)
  • Rust: edition 2024

PHP configure options

--prefix=/Users/ilzam/Private/oraphp/php/install
--enable-embed=shared
--enable-zts
--disable-zend-signals
--enable-mbstring
--enable-opcache
--with-openssl
--with-curl
--with-zlib
--with-iconv
--disable-cgi
--disable-phpdbg

Cargo.toml

[dependencies]
ext-php-rs = { version = "0.15", features = ["embed"] }

Errors

1. zend_hash_key_type_HASH_KEY_NON_EXISTENT removed/renamed

error[E0432]: unresolved import `crate::ffi::zend_hash_key_type_HASH_KEY_NON_EXISTENT`
  --> src/types/array/iterators.rs:20:5
   |
20 | use crate::ffi::zend_hash_key_type_HASH_KEY_NON_EXISTENT;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `zend_hash_key_type_HASH_KEY_NON_EXISTENT` in `ffi`

2. _zend_module_entry.globals_ptr renamed to globals_id_ptr

error[E0560]: struct `_zend_module_entry` has no field named `globals_ptr`
   --> src/builders/module.rs:686:13
    |
686 |             globals_ptr: builder.globals_ptr,
    |             ^^^^^^^^^^^ unknown field
    |
help: a field with a similar name exists
    |
686 |             globals_id_ptr: builder.globals_ptr,

3. _sapi_module_struct.pre_request_init no longer exists

error[E0560]: struct `_sapi_module_struct` has no field named `pre_request_init`
  --> src/builders/sapi.rs:99:17
   |
99 |                 pre_request_init: None,
   |                 ^^^^^^^^^^^^^^^^ `_sapi_module_struct` does not have this field

error[E0609]: no field `pre_request_init` on type `_sapi_module_struct`
   --> src/builders/sapi.rs:305:21
    |
305 |         self.module.pre_request_init = Some(func);
    |                     ^^^^^^^^^^^^^^^^ unknown field

Root Cause

PHP 8.4 introduced breaking changes to internal C structs:

  • _zend_module_entry.globals_ptr was renamed to globals_id_ptr
  • _sapi_module_struct.pre_request_init field was removed
  • zend_hash_key_type_HASH_KEY_NON_EXISTENT enum constant was removed or renamed

The current bindgen output reflects the new PHP 8.4 headers, but the Rust source code still references the old field/constant names.

Log Output

~/Private/oraphp master ?5 ❯ cargo run
   Compiling ext-php-rs v0.15.8 (https://github.com/davidcole1340/ext-php-rs#444d62a5)
error[E0432]: unresolved import `crate::ffi::zend_hash_key_type_HASH_KEY_NON_EXISTENT`
  --> /Users/ilzam/.cargo/git/checkouts/ext-php-rs-034fd0e09d5d4cea/444d62a/src/types/array/iterators.rs:20:5
   |
20 | use crate::ffi::zend_hash_key_type_HASH_KEY_NON_EXISTENT;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `zend_hash_key_type_HASH_KEY_NON_EXISTENT` in `ffi`

error[E0560]: struct `_zend_module_entry` has no field named `globals_ptr`
   --> /Users/ilzam/.cargo/git/checkouts/ext-php-rs-034fd0e09d5d4cea/444d62a/src/builders/module.rs:686:13
    |
686 |             globals_ptr: builder.globals_ptr,
    |             ^^^^^^^^^^^ unknown field
    |
help: a field with a similar name exists
    |
686 |             globals_id_ptr: builder.globals_ptr,
    |                     +++

error[E0560]: struct `_sapi_module_struct` has no field named `pre_request_init`
  --> /Users/ilzam/.cargo/git/checkouts/ext-php-rs-034fd0e09d5d4cea/444d62a/src/builders/sapi.rs:99:17
   |
99 |                 pre_request_init: None,
   |                 ^^^^^^^^^^^^^^^^ `_sapi_module_struct` does not have this field
   |
   = note: all struct fields are already assigned

error[E0609]: no field `pre_request_init` on type `_sapi_module_struct`
   --> /Users/ilzam/.cargo/git/checkouts/ext-php-rs-034fd0e09d5d4cea/444d62a/src/builders/sapi.rs:305:21
    |
305 |         self.module.pre_request_init = Some(func);
    |                     ^^^^^^^^^^^^^^^^ unknown field
    |
    = note: available fields are: `name`, `pretty_name`, `startup`, `shutdown`, `activate` ... and 31 others

Some errors have detailed explanations: E0432, E0560, E0609.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `ext-php-rs` (lib) due to 4 previous errors
~/Private/oraphp master ?5 ❯                                                                                   11s

Affected Components

  • ext-php-rs
  • macros
  • cli (cargo-php)

PHP Version

~/Private/oraphp master ?6 ❯ ~/Private/oraphp/php/install/bin/php --version                
PHP 8.4.11 (cli) (built: Apr 10 2026 22:49:02) (ZTS)
Copyright (c) The PHP Group
Zend Engine v4.4.11, Copyright (c) Zend Technologies
~/Private/oraphp master ?6 ❯

ext-php-rs Version

0.15.8 from crates.io and latest main branch (444d62a5).

Operating System

MacOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions