Skip to content

fix: Linux build — guard macOS Homebrew lib paths, fix libxml2 2.x sy… - #3

Closed
annmuor wants to merge 1 commit into
francescotinti:mainfrom
annmuor:fix/linux-build-libxml2-rename
Closed

annmuor wants to merge 1 commit into
francescotinti:mainfrom
annmuor:fix/linux-build-libxml2-rename

Conversation

@annmuor

@annmuor annmuor commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Two linker failures on Linux (libxml2 2.15.4 / Arch):

  1. crates/php-types/build.rs emitted -L /opt/homebrew/opt/gd/lib and -L /opt/homebrew/opt/tidy-html5/lib unconditionally. These paths don't exist on Linux; on Linux libgd and libtidy are in the default system library path. Wrapped both rustc-link-search lines in cfg!(target_os = "macos") guards.

  2. libxml2 2.x (shipped on Arch / modern Linux) renamed the XPath value-stack functions: valuePop → xmlXPathValuePop and valuePush → xmlXPathValuePush. The macOS system libxml2 (~2.9.x) still exports the old names. Added #[cfg_attr(not(target_os = "macos"), link_name = "...")] on the two FFI declarations in xsltio.rs so the correct symbol is resolved on each platform without touching any call sites.

Summary

  • crates/php-types/build.rs: Wrapped -L /opt/homebrew/opt/{gd,tidy-html5}/lib in cfg!(target_os = \"macos\") guards. These paths don't exist on Linux; libgd and libtidy are found via the default system library path there.
  • crates/php-types/src/xsltio.rs: Added #[cfg_attr(not(target_os = \"macos\"), link_name = \"xmlXPathValuePop/Push\")] on the two FFI declarations. libxml2 2.x (Arch/Linux) renamed valuePop→xmlXPathValuePop and valuePush→xmlXPathValuePush; macOS system libxml2 (~2.9.x) still uses the old names.

Test plan

  • cargo build --profile dev-release succeeds on Linux (Arch, libxml2 2.15.4)
  • macOS build still links against the old valuePop/valuePush symbols via the cfg_attr guard

🤖 Generated with Claude Code

…mbol renames

Two linker failures on Linux (libxml2 2.15.4 / Arch):

1. crates/php-types/build.rs emitted `-L /opt/homebrew/opt/gd/lib` and
   `-L /opt/homebrew/opt/tidy-html5/lib` unconditionally. These paths don't
   exist on Linux; on Linux libgd and libtidy are in the default system
   library path. Wrapped both `rustc-link-search` lines in `cfg!(target_os =
   "macos")` guards.

2. libxml2 2.x (shipped on Arch / modern Linux) renamed the XPath value-stack
   functions: `valuePop` → `xmlXPathValuePop` and `valuePush` →
   `xmlXPathValuePush`. The macOS system libxml2 (~2.9.x) still exports the
   old names. Added `#[cfg_attr(not(target_os = "macos"), link_name = "...")]`
   on the two FFI declarations in xsltio.rs so the correct symbol is resolved
   on each platform without touching any call sites.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
francescotinti pushed a commit that referenced this pull request Nov 2, 2026
…installed version, not by target OS (emend of PR #3)

PR #3 switched `valuePop`/`valuePush` to `xmlXPathValuePop`/`xmlXPathValuePush`
on every non-macOS target. The rename is a libxml2 >= 2.12 change (the old
names are gone by 2.15, the author's Arch), but Debian/Ubuntu still ship
libxml2 2.9.x, which only exports the old names: the PR would have broken
those Linux builds while fixing Arch.

build.rs now probes the installed version (`pkg-config --modversion
libxml-2.0`, then `xml2-config --version`; `PHPR_LIBXML_NEW_XPATH=1|0`
overrides) and emits `cfg(libxml_xpath_new_names)` from 2.12 on; xsltio.rs
keys the two `link_name` attributes on that cfg. macOS never probes (system
libxml2 2.9.13, verified in the SDK: `libxml2.tbd` exports `_valuePop`/
`_valuePush`), so the Mac binary links exactly as before. The Homebrew
`-L` guards of the PR are kept unchanged.

Linux is not verifiable on this machine; re-test requested on the PR.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@francescotinti

Copy link
Copy Markdown
Owner

Thanks — merged into main as a cherry-pick of your commit (authorship preserved) plus one follow-up:

  • your commit: b63ffb35
  • follow-up: 75c26b1e — build(php-types): pick the libxml2 XPath value-stack symbol names by installed version, not by target OS

Why the follow-up: the valuePop/valuePush → xmlXPathValuePop/xmlXPathValuePush rename is a libxml2 ≥ 2.12 change (old names gone by 2.15, your Arch), but Debian/Ubuntu still ship libxml2 2.9.x with only the old names, so not(target_os = "macos") would have broken those builds while fixing Arch. build.rs now probes the installed version (pkg-config --modversion libxml-2.0, fallback xml2-config --version; PHPR_LIBXML_NEW_XPATH=1|0 overrides) and emits cfg(libxml_xpath_new_names) from 2.12 on; xsltio.rs keys the two link_name attributes on that cfg. Your Homebrew -L guards are kept as they were. On macOS nothing changes (SDK libxml2 2.9.13 exports the old names, checked in libxml2.tbd).

I cannot build on Linux here. Could you re-run cargo build --profile dev-release on Arch from main? If you have a Debian/Ubuntu box with libxml2 2.9.x handy, a second data point would be welcome. If the probe misfires, PHPR_LIBXML_NEW_XPATH=1 is the escape hatch — please report it here.

Closing this PR since the commits are on main via cherry-pick (GitHub doesn't detect that as merged).

francescotinti pushed a commit that referenced this pull request Nov 2, 2026
… into s186-firma — REGOLE §5 frozen corpus 1407, §3.36 trait __CLASS__/__METHOD__ catalogued, NEXT scoreboard/pre-flight/openings, session verbal

Gates on the triage tree (dev-release): build rc=0, loc_dente rc=0 with no
cap raised, battery 1755/0 (+3 new dente), corpus-gate rc=0 (names == frozen
1407 x2 modes, content == golden 1404, off/on zero diffs), oracle diff
IDENTICAL on the filter_var and enum fixtures. Route B stays dead (S-186 bis
rc=4). S-188 order unchanged: O(1) cure v2 -> pin s184 -> t26/t28 pair ->
merge on user signature.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@annmuor

annmuor commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

I've built current main on my Arch - no issues, a few warnings on dead code. I've asked my colleague to build on Debian, will share the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants