Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<S
.map(|inc| format!("-I{}", inc.to_string_lossy())),
)
.clang_args(defines.iter().map(|(var, val)| format!("-D{var}={val}")))
// Define __bindgen so wrapper.h can detect it's being processed by bindgen
// and undefine HAVE_MUSTTAIL to prevent the preserve_none calling convention.
.clang_arg("-D__bindgen")
.formatter(bindgen::Formatter::Rustfmt)
.no_copy("php_ini_builder")
.no_copy("_zval_struct")
Expand Down
10 changes: 10 additions & 0 deletions src/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
#define __clang__
#endif

// Undefine HAVE_MUSTTAIL for bindgen to prevent PHP from using TAILCALL VM mode
// with the `preserve_none` calling convention which bindgen 0.72.x doesn't support.
// PHP 8.5+ on macOS ARM64 enables TAILCALL when both HAVE_MUSTTAIL and
// HAVE_PRESERVE_NONE are defined, causing bindgen to panic on unknown calling
// convention 20. This only affects binding generation, not PHP's runtime behavior.
// See: https://github.com/php/php-src/blob/PHP-8.5/Zend/zend_vm_opcodes.h#L45-L46
#if defined(__bindgen)
#undef HAVE_MUSTTAIL
#endif

#include "php.h"

#include "ext/standard/info.h"
Expand Down
Loading