Skip to content

Conversation

@ChrisRackauckas-Claude
Copy link
Contributor

Summary

This PR adds conditional compilation guards to make LinearSolve.jl GPL-safe when Julia is built without GPL libraries (USE_GPL_LIBS=0).

Changes

Files Modified:

  • src/factorization.jl: Guarded UMFPACKFactorization and CHOLMODFactorization struct definitions and methods
  • ext/LinearSolveSparseArraysExt.jl:
    • Guarded UMFPACK, CHOLMOD, and KLU-related constants and methods
    • Added fallback implementations for _ldiv! without SPQR/CHOLMOD
    • Guarded defaultalg dispatches that prefer GPL algorithms
    • Added alternative sparse LU handling without UMFPACK
  • src/LinearSolve.jl: Conditionally export GPL-dependent types
  • src/default.jl: Added error messages when GPL algorithms are selected without GPL libs

Behavior:

With GPL libs (Base.USE_GPL_LIBS=true) - Default Julia builds:

  • Everything works as before, using UMFPACK, KLU, CHOLMOD, and SPQR
  • No changes to existing functionality

Without GPL libs (Base.USE_GPL_LIBS=false):

  • Sparse LU falls back to SparspakFactorization (MIT licensed)
  • Symmetric sparse uses CholeskyFactorization instead of CHOLMOD
  • Sparse QR uses base Julia QR without SPQR
  • Clear error messages if users explicitly request GPL algorithms

Testing

  • Package compiles successfully with GPL libs enabled
  • Tests run successfully with GPL libs enabled
  • All SuiteSparse-dependent code paths are properly guarded

Motivation

This change allows LinearSolve.jl to be used in environments where Julia is built without GPL libraries, making it suitable for commercial/proprietary software that cannot use GPL dependencies.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

ChrisRackauckas and others added 3 commits October 6, 2025 20:25
This commit adds conditional compilation guards to make LinearSolve.jl
GPL-safe when Julia is built without GPL libraries (USE_GPL_LIBS=0).

Changes:
- Guard UMFPACKFactorization struct and dispatches
- Guard CHOLMODFactorization struct and dispatches
- Guard KLUFactorization dispatches (KLU is GPL)
- Guard SPQR (sparse QR) references in _ldiv! methods
- Add fallback error messages when GPL algorithms are used without GPL libs
- Conditionally export GPL-dependent types
- Add alternative defaultalg for sparse matrices without GPL libs

When USE_GPL_LIBS=0:
- Sparse LU falls back to SparspakFactorization (MIT licensed)
- Symmetric sparse uses CholeskyFactorization instead of CHOLMOD
- Sparse QR uses base Julia QR without SPQR

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Move `nothing`-returning init_cacheval methods outside GPL guards
  so they exist as fallbacks even without GPL libs
- Remove unnecessary QR/QRCompactWY fallbacks in _ldiv! - these are
  in base Julia, not GPL
- Keep SPQR.QRSparse and CHOLMOD.Factor _ldiv! methods guarded
- Remove conditional exports - algorithms can be exported but will
  error nicely when used without GPL libs
- More conservative guards: only guard code that directly uses
  SparseArrays.UMFPACK, SparseArrays.CHOLMOD, etc.

This ensures better compatibility and clearer error messages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changes:
- Revert all changes to src/factorization.jl - algorithms are always defined
- Add `else` branches in extension with informative solve! errors for GPL algorithms
- Fix `handle_sparsematrixcsc_lu` to use inline @static if instead of branches
- Guard KLUFactorization solve! and KLU-specific init_cacheval methods
- Keep fallback init_cacheval methods (returning `nothing`) outside guards

When USE_GPL_LIBS=false:
- Algorithms are still defined and exported
- Using them gives clear error: "requires GPL libraries, rebuild Julia with USE_GPL_LIBS=1"
- init_cacheval fallbacks exist but specific GPL type methods are unavailable

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ChrisRackauckas ChrisRackauckas merged commit c9549f2 into SciML:main Oct 7, 2025
133 of 136 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.

2 participants