Skip to content
Merged
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
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,11 @@ path = "tests/module.rs"
[[test]]
name = "sapi_tests"
path = "tests/sapi.rs"

# Patch clang-sys and bindgen for preserve_none calling convention support (libclang 19/20)
# Required for PHP 8.5+ on macOS ARM64 which uses TAILCALL VM mode
# - clang-sys: Adds libclang 19/20 bindings (https://github.com/KyleMayes/clang-sys/pull/195)
# - bindgen: Maps CXCallingConv_PreserveNone to C ABI
[patch.crates-io]
clang-sys = { git = "https://github.com/extphprs/clang-sys.git", branch = "preserve-none-support" }
bindgen = { git = "https://github.com/extphprs/rust-bindgen.git", branch = "preserve-none-support" }
22 changes: 21 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,27 @@ fn generate_bindings(defines: &[(&str, &str)], includes: &[PathBuf]) -> Result<S
.iter()
.map(|inc| format!("-I{}", inc.to_string_lossy())),
)
.clang_args(defines.iter().map(|(var, val)| format!("-D{var}={val}")))
.clang_args(defines.iter().map(|(var, val)| format!("-D{var}={val}")));

// Add macOS SDK path for system headers (stdlib.h, etc.)
// Required for libclang 19+ with preserve_none calling convention support
#[cfg(target_os = "macos")]
{
if let Ok(sdk_path) = std::process::Command::new("xcrun")
.args(["--show-sdk-path"])
.output()
{
if sdk_path.status.success() {
let path = String::from_utf8_lossy(&sdk_path.stdout);
let path = path.trim();
bindgen = bindgen
.clang_arg(format!("-isysroot{}", path))
.clang_arg(format!("-I{}/usr/include", path));
}
}
}

bindgen = bindgen
.formatter(bindgen::Formatter::Rustfmt)
.no_copy("php_ini_builder")
.no_copy("_zval_struct")
Expand Down
Loading