diff --git a/php-rust/crates/php-types/build.rs b/php-rust/crates/php-types/build.rs index f845ac00..cba6e556 100644 --- a/php-rust/crates/php-types/build.rs +++ b/php-rust/crates/php-types/build.rs @@ -4,14 +4,21 @@ // carries its own libjpeg-turbo/libpng/libwebp/libavif codec choices, so a // Rust-crate reimplementation (image/imageproc) would diverge on every encode. fn main() { - println!("cargo:rustc-link-search=native=/opt/homebrew/opt/gd/lib"); + // macOS: gd lives in a Homebrew keg, not the default library path. + // Linux: libgd is in the system library path; no explicit search needed. + if cfg!(target_os = "macos") { + println!("cargo:rustc-link-search=native=/opt/homebrew/opt/gd/lib"); + } println!("cargo:rustc-link-lib=dylib=gd"); // ext/xsl (src/xsltio.rs): the **system** libxslt/libexslt/libxml2 — the // same /usr/lib dylibs the PHP oracle links (they live in the dyld shared // cache; the linker resolves them through the SDK .tbd stubs). // ext/tidy (src/tidyio.rs): the **system** libtidy — the same Homebrew // keg the PHP oracle was configured against (--with-tidy=tidy-html5). - println!("cargo:rustc-link-search=native=/opt/homebrew/opt/tidy-html5/lib"); + // macOS: tidy lives in a Homebrew keg. Linux: system library path. + if cfg!(target_os = "macos") { + println!("cargo:rustc-link-search=native=/opt/homebrew/opt/tidy-html5/lib"); + } println!("cargo:rustc-link-lib=dylib=tidy"); println!("cargo:rustc-link-lib=dylib=xslt"); println!("cargo:rustc-link-lib=dylib=exslt"); diff --git a/php-rust/crates/php-types/src/xsltio.rs b/php-rust/crates/php-types/src/xsltio.rs index 63b1da99..53f61be2 100644 --- a/php-rust/crates/php-types/src/xsltio.rs +++ b/php-rust/crates/php-types/src/xsltio.rs @@ -438,7 +438,11 @@ const XPATH_NUMBER: c_int = 3; const XPATH_STRING: c_int = 4; extern "C" { + // macOS system libxml2 (~2.9.x) exports these as `valuePop`/`valuePush`; + // libxml2 2.x (Linux) renamed them to `xmlXPathValuePop`/`xmlXPathValuePush`. + #[cfg_attr(not(target_os = "macos"), link_name = "xmlXPathValuePop")] fn valuePop(ctxt: *mut c_void) -> *mut c_void; + #[cfg_attr(not(target_os = "macos"), link_name = "xmlXPathValuePush")] fn valuePush(ctxt: *mut c_void, value: *mut c_void) -> c_int; fn xmlXPathFreeObject(obj: *mut c_void); fn xmlXPathCastToString(obj: *mut c_void) -> *mut c_char;