Skip to content

Load all libraries through SuiteSparse_jll and update the generator to Clang.jl 0.19 - #55

Merged
ViralBShah merged 4 commits into
mainfrom
use-suitesparse-jll
Oct 31, 2026
Merged

ViralBShah merged 4 commits into
mainfrom
use-suitesparse-jll

Conversation

@ViralBShah

@ViralBShah ViralBShah commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Loads all SuiteSparse libraries through SuiteSparse_jll, the same way SparseArrays.jl does, and updates the wrapper generator to Clang.jl 0.19.

Loading libraries from the JLL

KLU.jl declared SuiteSparse_jll as a dependency, but nothing in src/ loaded it. It set const libklu = :libklu and left the library to be found by name. src/wrappers.jl also refers to libsuitesparseconfig, libbtf and libamd, which weren't defined anywhere in the module, so calling those wrappers threw UndefVarError. For example, KLU.SuiteSparse_config_malloc_func_get() did.

With using SuiteSparse_jll, all of these names come from the JLL, and src/, test/ and docs/make.jl no longer contain a literal library name. gen/generator.toml still has to spell out the binding names for Clang.jl, so the generator now asserts that each one is a binding of SuiteSparse_jll.

On Linux with Julia 1.13, main already loads the same file as Julia's own copy, lib/julia/libklu.so.2, so I don't expect a change there. What this adds is that KLU.jl no longer depends on that lookup finding the right file, which could differ on Windows, where a bare name goes through DLL search rules. I haven't shown that a wrong DLL has ever been loaded, so this isn't a known fix for #38.

Generator and wrappers

  • Clang.jl: 0.17 to 0.19.
  • Header path: the headers moved to include/suitesparse, so the generator failed before this.
  • colamd_* wrappers: these now use libcolamd. They pointed at libamd because colamd.h wasn't mapped.
  • Ignore list: adds SUITESPARSE_TIME and SUITESPARSE_CONFIG_TIMER, which would otherwise call C at load time or refer to an undefined name.

src/wrappers.jl is regenerated from SuiteSparse 7.10.1, with these effects:

  • Struct fields: no field changed from the previous wrappers, so the layouts match on the versions this package supports back to 7.2.
  • Mutability: klu_symbolic, klu_l_symbolic, klu_numeric and klu_l_numeric became immutable. KLU.jl only reads them through unsafe_load.
  • New wrappers: adds klu_version, amd_version, btf_version and colamd_version. These may not exist in older SuiteSparse versions, so they could fail if called on those. Nothing in KLU.jl calls them.
  • Version constants: they now report 7.10.1 whichever version is loaded, as they reported the previous version before. Nothing in KLU.jl's source uses them.

Generating for x86_64-w64-mingw32 and x86_64-linux-gnu gives byte-identical output, so one set of wrappers is correct for both. That rules out a difference in the generated bindings as a cause of the Windows reports.

Codecov

Adds codecov.yml, which excludes gen and src/wrappers.jl. The wrappers are generated, and most of them are never called, which held the project figure at about 52%. src/KLU.jl alone was at 95.8% when last measured, so expect the reported figure to jump. That's the change in what's counted, not new tests.

Testing

Two additions are folded into the existing "KLU Wrappers" testset: all five libraries are identical to the JLL's, and a libsuitesparseconfig wrapper is callable. The latter threw UndefVarError on main.

The full suite passes locally on Linux with Julia 1.10, 1.11, 1.12 and 1.13 at -t 2. Aqua and the docs build also pass. Windows has only been run through CI.

🤖 Generated with Claude Code

KLU.jl declared SuiteSparse_jll as a dependency but never loaded it, and found libklu through
the bare name :libklu. The other library names in wrappers.jl weren't defined at all, so calling
those wrappers threw UndefVarError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.54%. Comparing base (1c872bf) to head (2458624).

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #55       +/-   ##
===========================================
+ Coverage   73.17%   97.54%   +24.37%     
===========================================
  Files           2        1        -1     
  Lines         630      367      -263     
===========================================
- Hits          461      358      -103     
+ Misses        169        9      -160     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ViralBShah and others added 2 commits October 31, 2026 04:08
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The headers moved to include/suitesparse. Map colamd.h to libcolamd, as the amd.h pattern also
matched it, ignore two macros that would call C at load time, and check that every library name
is a binding of SuiteSparse_jll.

No struct field changed. Four structs became immutable, and they're only read with unsafe_load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ViralBShah ViralBShah changed the title Load libklu through SuiteSparse_jll Load all libraries through SuiteSparse_jll and update the generator to Clang.jl 0.19 Oct 31, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ViralBShah
ViralBShah merged commit a0e78a3 into main Oct 31, 2026
8 checks passed
@ViralBShah
ViralBShah deleted the use-suitesparse-jll branch October 31, 2026 04:16
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