Fix libxc 6.2.x support; refresh v7.1 headers from released 7.1.2 (v0.1.3) - #1
Merged
Merged
Conversation
…au fallback - Cargo: the workspace libxc-ffi dependency now sets default-features = false, so api-version features are selected exclusively through the libxc crate's features. Previously libxc-ffi's own defaults (api-v7_0 + dynamic_loading) were always unified in, and --no-default-features --features api-v6_2,dynamic_loading silently compiled the v7.0 struct layout of xc_func_type, reading garbage when a v6.2.2 shared library was loaded at runtime. - mGGA tau handling for libxc < 7.0: XC_FLAGS_NEEDS_TAU only exists in v7.0+. libxc 6.2.x reads the tau input for every meta-GGA functional, and xc_mgga_sanity_check aborts the process (exit(1)) when a tau-family output of a requested derivative order is NULL. The wrapper now falls back to the functional family in needs_tau() for < 7 libraries (mirrors pylibxc 6.2.2), substitutes zeroed scratch for null lapl/tau inputs, and allocates zeroed scratch (MggaExtraPtrs) for tau-family outputs missing from the layout or output pointer map. CUDA paths pass an empty map: 6.2.x has no GPU support, and v7.0+ gates tau on the flag. - tests: needs_tau assertion gated to v7+ libraries. Validated against 6.2.2/7.0.0/7.1.2 CPU and 7.0.0/7.1.2 CUDA shared libraries (full cargo test matrix, mGGA compute tests included). Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: glm-5.3 <service@zhipuai.cn>
…release libxc v7.1 is now released upstream (7.1.0-7.1.2). The bundled v7.1 headers were snapshotted from the devel branch before the release and differ from the released 7.1.2 tag: - xc_funcs_v7.1.h (XcFuncId v7_1 regenerated): add T_HLE17, LDA_C_BJ89, GGA_X_LLP, LDA_C_LP96_B, LDA_K_LP96_B, LDA_C_RPAF, HYB_MGGA_XC_COACH, MGGA_X_SREGTM_V1/V2/V3; remove MS2BS, MVSB, MVSBS, OPB3LYP, which never shipped in a released v7.1. All shared IDs keep their numbers. - xc.h: differences vs the 7.1.2 tag are comment-only (verified identical after comment stripping), so FFI bindings are unaffected; refreshed for provenance. xc_version.h macros updated 7.0.0 -> 7.1.2. While at it, xc_funcs_v6.2.h turned out not to be the 6.2.2 tag file either: it contained 44 functional IDs added after 6.2.2, a typo'd LDA_C_1D_CSS (real name LDA_C_1D_CSC), LDA_XC_TH_FL (real name GGA_XC_TH_FL), and was missing MGGA_X_MK00. Replaced with the 6.2.2 tag file and regenerated. Note that 7.1.2 itself renames 1D_CSC -> 1D_CSS and GGA_XC_TH_FL -> LDA_XC_TH_FL, so those variant names are version-dependent by design. xc_funcs_v7.0.h already matched the 7.0.0 tag exactly (regenerating it is byte-identical). Docs updated to reflect that v7.1 is a released line: readme, versioning_xc, CLAUDE.md, cuda-testing skill, and a CHANGELOG Unreleased entry covering this and the previous 6.2.x fix commit. Validated: cargo test -p libxc against 6.2.2/7.0.0/7.1.2 CPU and 7.1.2 CUDA shared libraries, all passing. Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: glm-5.3 <service@zhipuai.cn>
Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: glm-5.3 <service@zhipuai.cn>
…ustfmt - test-v7.0 workflow: add dynamic_loading to the feature list. The job ran cargo test --no-default-features --features="api-v7_0", which previously still loaded dynamically because libxc-ffi's default features were always unified in; after the feature isolation fix it compiled the static FFI and failed at link time with undefined xc_* symbols. Also pin conda-forge libxc to 7.0.*: the unpinned install now resolves to 7.1.2, which does not pair with api-v7_0 bindings by design. - cargo fmt --all: current rustfmt reflows over-width trailing comments, flagging functional_specific.rs and tests/regression/* untouched since May; compute_cpu.rs had two genuinely over-width lines from this PR. - CHANGELOG: note the CI workflow change under the v0.1.3 fix entry. Verified locally: cargo fmt --check clean; clippy --all-targets --all-features -D warnings clean; the exact CI test command passes against the 7.0.0 shared library. Co-authored-by: Claude Code <noreply@anthropic.com> Co-authored-by: glm-5.3-flash <service@zhipuai.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the FFI correctness revalidation against real 6.2.2 / 7.0.0 / 7.1.2 shared libraries. Four commits, targeting v0.1.3:
1. Fix libxc 6.2.x support
libxc-ffidependency now setsdefault-features = false, so api-version features are selected exclusively through thelibxccrate's features. Previously libxc-ffi's own defaults (api-v7_0+dynamic_loading) were always unified in, and--no-default-features --features api-v6_2,dynamic_loadingsilently compiled the v7.0 struct layout ofxc_func_type— reading garbage when a v6.2.2 shared library is loaded at runtime.XC_FLAGS_NEEDS_TAUonly exists in v7.0+. libxc 6.2.x reads the tau input for every meta-GGA functional, andxc_mgga_sanity_checkaborts the process (exit(1)) when a tau-family output of a requested derivative order is NULL. The wrapper now:needs_tau()for < 7 libraries (mirrors pylibxc 6.2.2),MggaExtraPtrs) for tau-family outputs missing from the layout or output pointer map. CUDA paths pass an empty map: 6.2.x has no GPU support, and v7.0+ gates tau on the flag.2. Refresh v7.1 headers from the released 7.1.2 tag
libxc v7.1 is now released upstream (7.1.0–7.1.2); the bundled v7.1 headers were snapshotted from the
develbranch before the release:xc_funcs_v7.1.h(XcFuncIdv7_1 regenerated): addT_HLE17,LDA_C_BJ89,GGA_X_LLP,LDA_C_LP96_B,LDA_K_LP96_B,LDA_C_RPAF,HYB_MGGA_XC_COACH,MGGA_X_SREGTM_V1/V2/V3; removeMS2BS,MVSB,MVSBS,OPB3LYP(never shipped in a released v7.1). All shared IDs keep their numbers.xc.h: differences vs 7.1.2 are comment-only (verified identical after comment stripping), so FFI bindings are unaffected; refreshed for provenance.xc_version.hmacros corrected 7.0.0 → 7.1.2.xc_funcs_v6.2.hturned out not to be the 6.2.2 tag file either: it contained 44 post-6.2.2 functional IDs, a typo'dLDA_C_1D_CSS(real nameLDA_C_1D_CSC),LDA_XC_TH_FL(real nameGGA_XC_TH_FL), and was missingMGGA_X_MK00. Replaced with the 6.2.2 tag file and regenerated. Note 7.1.2 itself renames1D_CSC→1D_CSSandGGA_XC_TH_FL→LDA_XC_TH_FL, so those variant names are version-dependent by design.xc_funcs_v7.0.halready matched the 7.0.0 tag exactly (regenerating is byte-identical).Docs updated to reflect that v7.1 is a released line: readme,
versioning_xc.md, CLAUDE.md, cuda-testing skill, CHANGELOG.3. Version bump to v0.1.3 (2026-09-08)
4. CI fixes
test-v7.0workflow: selectdynamic_loadingexplicitly — it silently relied on libxc-ffi's default features before the isolation fix, and failed at the link stage once those stopped being unified in — and pin conda-forgelibxcto7.0.*(conda-forge's default is now 7.1.2, which does not pair withapi-v7_0bindings by design).cargo fmt --all: current rustfmt reflows long trailing comments, flagging files untouched since May; includes two genuine over-width line splits incompute_cpu.rsfrom this PR.API impact
pub(crate).needs_tau()now returnstruefor every mGGA/hyb-mGGA when the loaded library is v6.2.x (matches pylibxc 6.2.2); unchanged for v7.x.XcFuncIdvariant sets change underapi-v7_1(+10/−4) andapi-v6_2(+3/−45). The removed variants never worked against real released libraries, so this is a correctness fix.default-features = false, building without any api feature now fails loudly (unresolved imports) instead of silently compiling v7.0 defaults.Validation
cargo test -p libxcagainst locally built shared libraries, all passing (mGGA compute tests included):--no-default-features --features api-v6_2,dynamic_loadingapi-v7_0)api-v7_1cudacuda,api-v7_1Feature isolation verified via
cargo tree -f "{p} [{f}]": libxc-ffi resolves to[api-v6_2, dynamic_loading]only under the v6.2 selection.