Skip to content

Commit 94a0ee8

Browse files
authored
build: Remove GPL libs when set USE_GPL_LIBS=0 (JuliaLang#54240)
Fix JuliaLang#53211
1 parent da23114 commit 94a0ee8

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed

Makefile

+6-1
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@ JL_PRIVATE_LIBS-0 += libjulia-internal libjulia-codegen
206206
else ifeq ($(JULIA_BUILD_MODE),debug)
207207
JL_PRIVATE_LIBS-0 += libjulia-internal-debug libjulia-codegen-debug
208208
endif
209+
# BSD-3-Clause
210+
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBSUITESPARSE) += libamd libcamd libccolamd libcolamd libsuitesparseconfig
211+
# LGPL-2.1+
212+
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBSUITESPARSE) += libbtf libklu libldl
209213
ifeq ($(USE_GPL_LIBS), 1)
210-
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBSUITESPARSE) += libamd libbtf libcamd libccolamd libcholmod libcolamd libklu libldl librbio libspqr libsuitesparseconfig libumfpack
214+
# GPL-2.0+
215+
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBSUITESPARSE) += libcholmod librbio libspqr libumfpack
211216
endif
212217
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBBLASTRAMPOLINE) += libblastrampoline
213218
JL_PRIVATE_LIBS-$(USE_SYSTEM_PCRE) += libpcre2-8

THIRDPARTY.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,19 @@ Julia's `stdlib` uses the following external libraries, which have their own lic
4242
- [OPENBLAS](https://raw.github.com/xianyi/OpenBLAS/master/LICENSE) [BSD-3]
4343
- [LAPACK](https://netlib.org/lapack/LICENSE.txt) [BSD-3]
4444
- [PCRE](https://www.pcre.org/licence.txt) [BSD-3]
45-
- [SUITESPARSE](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/master/LICENSE.txt) [mix of LGPL2+ and GPL2+; see individual module licenses]
45+
- [SUITESPARSE](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/master/LICENSE.txt) [mix of BSD-3-Clause, LGPL2.1+ and GPL2+; see individual module licenses]
46+
- [`libamd`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/AMD/Doc/License.txt) [BSD-3-Clause]
47+
- [`libcamd`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/CAMD/Doc/License.txt) [BSD-3-Clause]
48+
- [`libccolamd`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/CCOLAMD/Doc/License.txt) [BSD-3-Clause]
49+
- [`libcolamd`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/COLAMD/Doc/License.txt) [BSD-3-Clause]
50+
- [`libsuitesparseconfig`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/SuiteSparse_config/README.txt) [BSD-3-Clause]
51+
- [`libbtf`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/BTF/Doc/License.txt) [LGPL-2.1+]
52+
- [`libklu`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/KLU/Doc/License.txt) [LGPL-2.1+]
53+
- [`libldl`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/LDL/Doc/License.txt) [LGPL-2.1+]
54+
- [`libcholmod`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/CHOLMOD/Doc/License.txt) [LGPL-2.1+ and GPL-2.0+]
55+
- [`librbio`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/RBio/Doc/License.txt) [GPL-2.0+]
56+
- [`libspqr`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/SPQR/Doc/License.txt) [GPL-2.0+]
57+
- [`libumfpack`](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/UMFPACK/Doc/License.txt) [GPL-2.0+]
4658
- [LIBBLASTRAMPOLINE](https://github.com/staticfloat/libblastrampoline/blob/main/LICENSE) [MIT]
4759
- [NGHTTP2](https://github.com/nghttp2/nghttp2/blob/master/COPYING) [MIT]
4860

deps/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ ifeq ($(USE_SYSTEM_MPFR), 0)
143143
DEP_LIBS += mpfr
144144
endif
145145

146-
ifeq ($(USE_GPL_LIBS), 1)
146+
# Only some of the modules in SuiteSparse are GPL.
147+
# xref: `remove-libsuitesparse-gpl-lib` in libsuitesparse.mk
147148
ifeq ($(USE_SYSTEM_LIBSUITESPARSE), 0)
148149
DEP_LIBS += libsuitesparse
149150
endif
150-
endif
151151

152152
ifeq ($(USE_SYSTEM_UTF8PROC), 0)
153153
DEP_LIBS += utf8proc

deps/libsuitesparse.mk

+14-1
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,31 @@ configure-libsuitesparse: extract-libsuitesparse
9595
compile-libsuitesparse: $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-compiled
9696
fastcheck-libsuitesparse: #none
9797
check-libsuitesparse: $(BUILDDIR)/SuiteSparse-$(LIBSUITESPARSE_VER)/build-checked
98-
install-libsuitesparse: $(build_prefix)/manifest/libsuitesparse
98+
install-libsuitesparse: $(build_prefix)/manifest/libsuitesparse remove-libsuitesparse-gpl-lib
9999

100100
else # USE_BINARYBUILDER_LIBSUITESPARSE
101101

102102
$(eval $(call bb-install,libsuitesparse,LIBSUITESPARSE,false))
103103

104104
# libsuitesparse depends on blastrampoline
105105
compile-libsuitesparse: | $(build_prefix)/manifest/blastrampoline
106+
install-libsuitesparse: | remove-libsuitesparse-gpl-lib
106107
endif
107108

108109
define manual_libsuitesparse
109110
uninstall-libsuitesparse:
110111
-rm -f $(build_prefix)/manifest/libsuitesparse
111112
-rm -f $(addprefix $(build_shlibdir)/lib,$3)
112113
endef
114+
115+
remove-libsuitesparse-gpl-lib:
116+
ifeq ($(USE_GPL_LIBS),1)
117+
@echo This build contains [GPL-2.0+] libs: libcholmod librbio libspqr libumfpack
118+
else
119+
@echo Removing GPL libs...
120+
-rm -f $(build_bindir)/libcholmod*
121+
-rm -f $(build_bindir)/libklu_cholmod*
122+
-rm -f $(build_bindir)/librbio*
123+
-rm -f $(build_bindir)/libspqr*
124+
-rm -f $(build_bindir)/libumfpack*
125+
endif

stdlib/SuiteSparse_jll/src/SuiteSparse_jll.jl

+21-16
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,34 @@ else
8181
end
8282

8383
function __init__()
84+
# BSD-3-Clause
85+
global libamd_handle = dlopen(libamd)
86+
global libamd_path = dlpath(libamd_handle)
87+
global libcamd_handle = dlopen(libcamd)
88+
global libcamd_path = dlpath(libcamd_handle)
89+
global libccolamd_handle = dlopen(libccolamd)
90+
global libccolamd_path = dlpath(libccolamd_handle)
91+
global libcolamd_handle = dlopen(libcolamd)
92+
global libcolamd_path = dlpath(libcolamd_handle)
93+
global libsuitesparseconfig_handle = dlopen(libsuitesparseconfig)
94+
global libsuitesparseconfig_path = dlpath(libsuitesparseconfig_handle)
95+
96+
# LGPL-2.1+
97+
global libbtf_handle = dlopen(libbtf)
98+
global libbtf_path = dlpath(libbtf_handle)
99+
global libklu_handle = dlopen(libklu)
100+
global libklu_path = dlpath(libklu_handle)
101+
global libldl_handle = dlopen(libldl)
102+
global libldl_path = dlpath(libldl_handle)
103+
104+
# GPL-2.0+
84105
if Base.USE_GPL_LIBS
85-
global libamd_handle = dlopen(libamd)
86-
global libamd_path = dlpath(libamd_handle)
87-
global libbtf_handle = dlopen(libbtf)
88-
global libbtf_path = dlpath(libbtf_handle)
89-
global libcamd_handle = dlopen(libcamd)
90-
global libcamd_path = dlpath(libcamd_handle)
91-
global libccolamd_handle = dlopen(libccolamd)
92-
global libccolamd_path = dlpath(libccolamd_handle)
93106
global libcholmod_handle = dlopen(libcholmod)
94107
global libcholmod_path = dlpath(libcholmod_handle)
95-
global libcolamd_handle = dlopen(libcolamd)
96-
global libcolamd_path = dlpath(libcolamd_handle)
97-
global libklu_handle = dlopen(libklu)
98-
global libklu_path = dlpath(libklu_handle)
99-
global libldl_handle = dlopen(libldl)
100-
global libldl_path = dlpath(libldl_handle)
101108
global librbio_handle = dlopen(librbio)
102109
global librbio_path = dlpath(librbio_handle)
103110
global libspqr_handle = dlopen(libspqr)
104111
global libspqr_path = dlpath(libspqr_handle)
105-
global libsuitesparseconfig_handle = dlopen(libsuitesparseconfig)
106-
global libsuitesparseconfig_path = dlpath(libsuitesparseconfig_handle)
107112
global libumfpack_handle = dlopen(libumfpack)
108113
global libumfpack_path = dlpath(libumfpack_handle)
109114
end

0 commit comments

Comments
 (0)