Skip to content

Commit 5b56232

Browse files
ChrisRackauckas-ClaudeChrisRackauckasclaude
authored
Add GPL guards for CHOLMOD usage to make Enzyme.jl GPL-safe (#2650)
This commit adds `@static if Base.USE_GPL_LIBS` guards around all CHOLMOD-related dispatches in Enzyme.jl. This ensures that when Julia is built without GPL libraries, Enzyme.jl remains license-compatible. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: ChrisRackauckas <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent 9e2c50d commit 5b56232

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/absint.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,12 @@ function abs_typeof(
608608
# add the extra poitner offset when loading here]. However for pointers constructed by ccall outside julia
609609
# to a julia object, which are not inline by type but appear so, like SparseArrays, this is a problem
610610
# and merits further investigation. x/ref https://github.com/EnzymeAD/Enzyme.jl/issues/2085
611-
if !Base.allocatedinline(typ) && typ != SparseArrays.cholmod_dense_struct && typ != SparseArrays.cholmod_sparse_struct && typ != SparseArrays.cholmod_factor_struct
611+
@static if Base.USE_GPL_LIBS
612+
cholmod_exception = typ != SparseArrays.cholmod_dense_struct && typ != SparseArrays.cholmod_sparse_struct && typ != SparseArrays.cholmod_factor_struct
613+
else
614+
cholmod_exception = true
615+
end
616+
if !Base.allocatedinline(typ) && cholmod_exception
612617
shouldLoad = false
613618
offset %= sizeof(Int)
614619
else

src/analyses/activity.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ end
1919
@inline ptreltype(::Type{Tuple{Vararg{T}}}) where {T} = T
2020
@inline ptreltype(::Type{IdDict{K,V}}) where {K,V} = V
2121
@inline ptreltype(::Type{IdDict{K,V} where K}) where {V} = V
22+
@static if Base.USE_GPL_LIBS
2223
@inline ptreltype(::Type{SparseArrays.CHOLMOD.Dense{T}}) where T = T
24+
end
2325
@static if VERSION < v"1.11-"
2426
else
2527
@inline ptreltype(::Type{Memory{T}}) where T = T
@@ -33,7 +35,9 @@ end
3335
@inline is_arrayorvararg_ty(::Type{Base.RefValue{T}}) where {T} = true
3436
@inline is_arrayorvararg_ty(::Type{IdDict{K,V}}) where {K,V} = true
3537
@inline is_arrayorvararg_ty(::Type{IdDict{K,V} where K}) where {V} = true
38+
@static if Base.USE_GPL_LIBS
3639
@inline is_arrayorvararg_ty(::Type{SparseArrays.CHOLMOD.Dense{T}}) where T = true
40+
end
3741
@static if VERSION < v"1.11-"
3842
else
3943
@inline is_arrayorvararg_ty(::Type{Memory{T}}) where T = true

0 commit comments

Comments
 (0)