# Does using GSL.jl mean I have to release my package under GPL?

**URL:** <https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654>\
**Category:** Community\
**Tags:** licenses, gpl\
**Created:** [April 7, 2024, 8:03pm UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654 "2024-04-07T20:03:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)\
**Post date:** [April 7, 2024, 8:03pm UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654/1 "2024-04-07T20:03:38Z")

</div>

I’m currently writing a project/package that has `using GSL` in its source file and `GSL = "92c[...]"` under `Project.toml`’s `[deps]` section. GSL.jl is the wrapper for the GNU Scientific Library (GSL), which is explicitly part of the GNU project, and both GSL and GSL.jl are released under the GPL. I’m inclined to release my project under the MIT License, but I’m unsure if that’s legally allowed. I’ve read through the GNU page for GPL associated works, and derivatives/conveyances, and a lot of it works around providing binaries as well, and the terms around source distribution seems murky to me. However, I’ll only be releasing the .jl source files in GitHub (and hopefully submitting the package to the Julia General registry), and I’m not sure what licensing requirements I must adhere to.  
My work is of particular interest to academics. While I’m not opposed to releasing under GPL, it may limit what people can do with my code, because it may also come in proprietary use.

Pages I’ve checked for an answer:

- [Frequently Asked Questions about the GNU Licenses - GNU Project - Free Software Foundation](https://www.gnu.org/licenses/gpl-faq.html)
- [Frequently Asked Questions about the GNU GPL v2.0 - GNU Project - Free Software Foundation](https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.en.html)
- [Source-only distribution of MIT-licensed project which depends on GPL library - Open Source Stack Exchange](https://opensource.stackexchange.com/questions/10365/source-only-distribution-of-mit-licensed-project-which-depends-on-gpl-library)
- [Licensing Julia Wrappers](https://discourse.julialang.org/t/licensing-julia-wrappers/38973)
- [licensing - GPL-3.0 library in MIT project - Open Source Stack Exchange](https://opensource.stackexchange.com/questions/9728/gpl-3-0-library-in-mit-project)
- [licensing - Do I have to open source my project if I use a piece of code licensed under GPL as a part of my project? - Stack Overflow](https://stackoverflow.com/questions/2444432/do-i-have-to-open-source-my-project-if-i-use-a-piece-of-code-licensed-under-gpl)

TL;DR:

- Using a GPL v3 Licensed Julia library as a dependency
- Want to release my code under MIT License
- Possible?

As an alternative, the only functionality I need from GSL.jl is its ability to compute associated Legendre polynomials and its first and second derivatives for many (_ℓ_,_m_) at once, so if someone knows of an alternative with more compatible licensing, please let me know! 🙂

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 7, 2024, 9:27pm UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654/2 "2024-04-07T21:27:12Z")

</div>

I am afraid that the chances are low to get legal advice in this forum. Sorry!

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [April 7, 2024, 9:42pm UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654/3 "2024-04-07T21:42:27Z")

</div>

Pretty much no answer given here or on another forum such as stackexchange is going to be 100% accurate, because what exactly is copyrightable depends on your jurisdiction & what a judge presiding over an eventual case rules. E.g. under EU law, there are certain exceptions (see [here](https://joinup.ec.europa.eu/collection/eupl/news/why-viral-licensing-ghost)) that can be viewed as “virality as the FSF claims it to exist doesn’t work in the EU”. Whether that applies to you is up to your discretion, and if there are too many doubts, asking an actual IP lawyer familiar with your jurisdiction is going to be more fruitful. Alternatively, going with the license of GSL.jl is a safe bet.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 7, 2024, 10:15pm UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654/4 "2024-04-07T22:15:42Z")

</div>

> [@Abhro](#):
>
> I’m inclined to release my project under the MIT License, but I’m unsure if that’s legally allowed.

You can look at what the FSF has written with the benefit of legal counsel and years of experience with their licenses. According to them, the [MIT (“expat”) License is compatible with the GPL](https://www.gnu.org/licenses/license-list.en.html#Expat), so this is allowed. According to the FSF’s [GPL FAQ](https://www.gnu.org/licenses/gpl-faq.html#IfLibraryIsGPL):

> _If a library is released under the GPL (not the LGPL), does that mean that any software which uses it has to be under the GPL or a GPL-compatible license?_ Yes, because the program actually links to the library. As such, the terms of the GPL apply to the entire combination. **The software modules that link with the library may be under various GPL compatible licenses, but the work as a whole must be licensed under the GPL.** _[emphasis added]_

So your package, which links to the GPL’ed library (GSL in this case) can be under any GPL-compatible license (e.g. MIT), but the software as a whole (your code + GSL) is governed by the union of all the license terms (= GPL, since the GPL restrictions are a strict superset of the MIT license).

So, for example, if Microsoft wanted to use your package in the next version of Excel, they would pull in the GSL dependency (assuming your software doesn’t work without it) and hence the GPL terms. On the other hand, if they were to take your code and then replace the GSL calls with some equivalent replacement under a different license, then they would probably only have to worry about your code’s license (e.g. MIT).

IANAL, and even the FSF’s legal opinion cannot be 100% certain (in an actual court case there is some uncertainty in what a judge/jury will decide), but the FSF has a few decade’s experience in [enforcing the GPL](https://www.gnu.org/philosophy/enforcing-gpl.html) so their interpretation seems like a reasonably good bet.

PS. When creating a package that has a GPL dependency, in my opinion it is sometimes clearer to put your package under the GPL too, to make sure the package users don’t miss the GPL requirements (though this prevents the users from modifying your package to strip out the GPL by replacing the GSL calls with something else). Even if you use the MIT license for your own code, I would clearly mention that you have a GPL dependency. However, this has already been done for the GSL.jl package (which is [GPL licensed](https://github.com/JuliaMath/GSL.jl/blob/921221e1a5e9481158886a5ae6ba3608422ef6b7/LICENSE.md), like the underlying GSL C library).

PPS. Out of curiosity, which GSL function(s) are you using? A lot of GSL functions have equivalent or better replacements elsewhere in the Julia ecosystem.

PPPS. The general principles here stem from copyright law in general, not just for GPL code. If you write software that combines code derived from A, B, and C, then (US) copyright law tells you that the combined work needs to abide by the union of the terms of A, B, and C. Some terms are less restrictive than the GPL (e.g. MIT license) and some are more restrictive than the GPL (e.g. proprietary software). Some terms are mutually incompatible (e.g. the GPL license for A and a proprietary license for B), making it impossible to distribute the combined work because you can’t simultaneously abide by all of the license terms — this is why some licenses are “GPL-incompatible”. The more permissive the licenses are (e.g. MIT and 3-clause BSD are two of the most permissive), of course, the easier abiding by all of the terms becomes and the less likely they are to be incompatible.

---

<div class="post-metadata">

**Author:** ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)\
**Post date:** [April 7, 2024, 11:19pm UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654/5 "2024-04-07T23:19:58Z")

</div>

> [@stevengj](#):
>
> So your package, which links to the GPL’ed library (GSL in this case) can be under any GPL-compatible license (e.g. MIT), but the software as a whole (your code + GSL) is governed by the union of all the license terms (= GPL, since the GPL restrictions are a strict superset of the MIT license).

Thanks! The problem I’d been having was with “linking”, and how distribution works with source vs. binary distribution, and I couldn’t properly distinguish between legal/colloquial linking and linking in the compilation sense.

> [@stevengj](#):
>
> PPS. Out of curiosity, which GSL function(s) are you using? A lot of GSL functions have equivalent or better replacements elsewhere in the Julia ecosystem.

The main GSL function I’m using is `gsl_sf_legendre_deriv2_array_e`, which calculates the associated Legendre polynomial and its first and second derivatives for multiple (_ℓ_,_m_). I’ve looked at LegendrePolynomials.jl and AssociatedLegendrePolynomials.jl, but neither of them provides the functionality for calculating _derivatives_ out of the box for the _associated_ Legendre functions. Perhaps when I have the time, I can contribute the code for that haha 😅. Afaik, GSL also handles different normalizations for the associated Legendre polynomials really well, and LegendrePolynomials.jl does too, but it becomes thorny when derivatives are involved.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [April 8, 2024, 1:26am UTC](https://discourse.julialang.org/t/does-using-gsl-jl-mean-i-have-to-release-my-package-under-gpl/112654/6 "2024-04-08T01:26:51Z")

</div>

> [@Abhro](#):
>
> neither of them provides the functionality for calculating _derivatives_ out of the box for the _associated_ Legendre functions.

They don’t need to. Since they are implemented with type-generic Julia code (presumably just recurrence relations), ForwardDiff.jl can differentiate them just fine:

```julia-auto
julia> using LegendrePolynomials, ForwardDiff

julia> Plm(0.5, 3, 2) # associated Legendre polynomial
5.624999999999997

julia> Plm′(x, ℓ, m) = ForwardDiff.derivative(x -> Plm(x, ℓ, m), x) # its derivative
Plm′ (generic function with 1 method)

julia> Plm′(0.5, 3, 2)
3.7499999999999973

```

As you’d hope, evaluating the derivative is basically the same cost as evaluating the function:

```julia-auto
julia> using BenchmarkTools

julia> @btime Plm(0.5, 3, 2);
  132.144 ns (0 allocations: 0 bytes)

julia> @btime Plm′(0.5, 3, 2);
  134.959 ns (0 allocations: 0 bytes)

```

However, LegendrePolynomials.jl seems to be leaving some performance (and accuracy?) on the table ([slow compared to AssociatedLegendrePolynomials.jl and to GSL.jl · Issue #18 · jishnub/LegendrePolynomials.jl · GitHub](https://github.com/jishnub/LegendrePolynomials.jl/issues/18)). AssociatedLegendrePolynomials.jl is faster:

```julia-auto
julia> import AssociatedLegendrePolynomials

julia> @btime AssociatedLegendrePolynomials.Plm(3, 2, 0.5)
  34.540 ns (6 allocations: 96 bytes)
5.625

julia> @btime ForwardDiff.derivative(x -> AssociatedLegendrePolynomials.Plm(3, 2, x), 0.5)
  54.234 ns (6 allocations: 192 bytes)
3.75

```

but this is also losing some performance because it allocates, even if you use its “in-place” API:

```julia-auto
julia> P = fill(NaN); # 0-dimensional array to hold the result

julia> @btime AssociatedLegendrePolynomials.Plm!($P, 3, 2, 0.5)
  30.920 ns (5 allocations: 80 bytes)
0-dimensional Array{Float64, 0}:
5.625

```

GSL is currently slightly faster than `AssociatedLegendrePolynomials.Plm!`

```julia-auto
julia> import GSL

julia> @btime GSL.sf_legendre_Plm(3, 2, 0.5)
  27.088 ns (0 allocations: 0 bytes)
5.625

```

They are probably all using the same recurrences, but LegendrePolynomials.jl is hiding it behind an [iterator-based implementation](https://github.com/jishnub/LegendrePolynomials.jl/blob/f14f023d2ebfc07a911fd4cb541a9985d8b5ed4d/src/LegendrePolynomials.jl#L272) that I’m guessing is failing to inline or something?
