Skip to content

Commit 857c097

Browse files
committed
feat: update Makefile to correctly link -lz for Linux and Android platforms
1 parent 4f13bd4 commit 857c097

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

extensions/sqlite/Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,18 @@ ifneq ($(GGML_OPENCL_LIB),)
120120
LLAMA_LIBS += $(GGML_OPENCL_LIB)
121121
endif
122122

123-
# Default link libs. Windows is fully overridden in its branch below
124-
# because -lpthread doesn't exist on MinGW (we use -lwinpthread instead)
125-
# and -lz needs to sit after the static libs, not before.
123+
# Default link libs. -lz is appended to LIBS (not LDFLAGS) for every
124+
# platform that uses libcurl — libcurl references inflate*, and with
125+
# single-pass GNU ld + --as-needed, -lz must sit AFTER libcurl.a or
126+
# libz.so gets dropped from DT_NEEDED. glibc loaders happen to find
127+
# inflateEnd through the global namespace anyway; musl is strict and
128+
# fails dlopen with "Error relocating: inflateEnd: symbol not found".
126129
ifeq ($(PLATFORM),android)
127-
LDFLAGS := -lz
130+
LDFLAGS :=
128131
else ifeq ($(PLATFORM),windows)
129132
LDFLAGS :=
130133
else
131-
LDFLAGS := -lpthread -lz
134+
LDFLAGS := -lpthread
132135
endif
133136

134137
# ----------------------------------------------------------------------------
@@ -204,6 +207,7 @@ else ifeq ($(PLATFORM),android)
204207
LIBS += $(MBEDTLS_BUILD)/library/libmbedtls.a
205208
LIBS += $(MBEDTLS_BUILD)/library/libmbedx509.a
206209
LIBS += $(MBEDTLS_BUILD)/library/libmbedcrypto.a
210+
LIBS += -lz
207211
else
208212
# linux (default)
209213
EXT := so
@@ -214,6 +218,7 @@ else
214218
LIBS += $(MBEDTLS_BUILD)/library/libmbedtls.a
215219
LIBS += $(MBEDTLS_BUILD)/library/libmbedx509.a
216220
LIBS += $(MBEDTLS_BUILD)/library/libmbedcrypto.a
221+
LIBS += -lz
217222
endif
218223

219224
# Vulkan / OpenCL runtime loaders. Must come AFTER the ggml-vulkan/-opencl

0 commit comments

Comments
 (0)