You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add @static if Base.USE_GPL_LIBS guards for SuiteSparse usage (#797)
* Add @static if Base.USE_GPL_LIBS guards for SuiteSparse usage
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>
* Refine GPL guards: keep init_cacheval stubs and exports
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>
* Fix GPL guards: revert factorization.jl, add solve! error branches
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>
---------
Co-authored-by: ChrisRackauckas <me@chrisrackauckas.com>
Co-authored-by: Claude <noreply@anthropic.com>
error("UMFPACKFactorization requires GPL libraries (UMFPACK). Rebuild Julia with USE_GPL_LIBS=1 or use an alternative algorithm like SparspakFactorization")
240
+
end
241
+
242
+
end# @static if Base.USE_GPL_LIBS
216
243
217
244
function LinearSolve.init_cacheval(
218
245
alg::KLUFactorization, A::AbstractArray, b, u, Pl,
@@ -222,14 +249,6 @@ function LinearSolve.init_cacheval(
222
249
nothing
223
250
end
224
251
225
-
function LinearSolve.init_cacheval(
226
-
alg::KLUFactorization, A::AbstractSparseArray{Float64, Int64}, b, u, Pl, Pr,
227
-
maxiters::Int, abstol,
228
-
reltol,
229
-
verbose::Bool, assumptions::OperatorAssumptions)
230
-
PREALLOCATED_KLU
231
-
end
232
-
233
252
function LinearSolve.init_cacheval(
234
253
alg::KLUFactorization, A::LinearSolve.GPUArraysCore.AnyGPUArray, b, u,
235
254
Pl, Pr,
@@ -238,6 +257,19 @@ function LinearSolve.init_cacheval(
alg::KLUFactorization, A::AbstractSparseArray{Float64, Int64}, b, u, Pl, Pr,
267
+
maxiters::Int, abstol,
268
+
reltol,
269
+
verbose::Bool, assumptions::OperatorAssumptions)
270
+
PREALLOCATED_KLU
271
+
end
272
+
241
273
function LinearSolve.init_cacheval(
242
274
alg::KLUFactorization, A::AbstractSparseArray{Float64, Int32}, b, u, Pl, Pr,
243
275
maxiters::Int, abstol,
@@ -247,7 +279,6 @@ function LinearSolve.init_cacheval(
247
279
0, 0, [Int32(1)], Int32[], Float64[]))
248
280
end
249
281
250
-
#TODO: guard this against errors
251
282
function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::KLUFactorization; kwargs...)
252
283
A = cache.A
253
284
A =convert(AbstractMatrix, A)
@@ -282,6 +313,24 @@ function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::KLUFactorization;
282
313
end
283
314
end
284
315
316
+
else
317
+
318
+
function SciMLBase.solve!(cache::LinearSolve.LinearCache, alg::KLUFactorization; kwargs...)
319
+
error("KLUFactorization requires GPL libraries (KLU/SuiteSparse). Rebuild Julia with USE_GPL_LIBS=1 or use an alternative algorithm like SparspakFactorization")
320
+
end
321
+
322
+
end# @static if Base.USE_GPL_LIBS
323
+
324
+
function LinearSolve.init_cacheval(alg::CHOLMODFactorization,
0 commit comments