Skip to content

Fix libxc 6.2.x support; refresh v7.1 headers from released 7.1.2 (v0.1.3) - #1

Merged
ajz34 merged 4 commits into
RESTGroup:mainfrom
ajz34:260908-revalidate
Sep 9, 2026
Merged

ajz34 merged 4 commits into
RESTGroup:mainfrom
ajz34:260908-revalidate

Conversation

@ajz34

@ajz34 ajz34 commented Sep 8, 2026

Copy link
Copy Markdown
Member

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

  • Cargo feature isolation: 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 is 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,
    • 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.

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 devel branch before the release:

  • 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 (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.h macros corrected 7.0.0 → 7.1.2.
  • xc_funcs_v6.2.h turned out not to be the 6.2.2 tag file either: it contained 44 post-6.2.2 functional IDs, 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 7.1.2 itself renames 1D_CSC1D_CSS and GGA_XC_TH_FLLDA_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 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.0 workflow: select dynamic_loading explicitly — 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-forge libxc to 7.0.* (conda-forge's default is now 7.1.2, which does not pair with api-v7_0 bindings by design).
  • cargo fmt --all: current rustfmt reflows long trailing comments, flagging files untouched since May; includes two genuine over-width line splits in compute_cpu.rs from this PR.

API impact

  • No public function signatures change; all new internals are pub(crate).
  • Behavioral: needs_tau() now returns true for every mGGA/hyb-mGGA when the loaded library is v6.2.x (matches pylibxc 6.2.2); unchanged for v7.x.
  • XcFuncId variant sets change under api-v7_1 (+10/−4) and api-v6_2 (+3/−45). The removed variants never worked against real released libraries, so this is a correctness fix.
  • With default-features = false, building without any api feature now fails loudly (unresolved imports) instead of silently compiling v7.0 defaults.

Validation

cargo test -p libxc against locally built shared libraries, all passing (mGGA compute tests included):

libxc variant features
6.2.2 CPU --no-default-features --features api-v6_2,dynamic_loading
7.0.0 CPU default (api-v7_0)
7.1.2 CPU api-v7_1
7.0.0 CUDA cuda
7.1.2 CUDA cuda,api-v7_1

Feature isolation verified via cargo tree -f "{p} [{f}]": libxc-ffi resolves to [api-v6_2, dynamic_loading] only under the v6.2 selection.

ajz34 and others added 4 commits September 8, 2026 21:02
…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>
@ajz34
ajz34 merged commit 26e8779 into RESTGroup:main Sep 9, 2026
3 checks passed
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.

1 participant