zstd-ruby 1.5.1.0 → 1.5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +56 -3
- data/Rakefile +8 -2
- data/ext/zstdruby/{zstdruby.h → common.h} +2 -0
- data/ext/zstdruby/extconf.rb +1 -1
- data/ext/zstdruby/libzstd/common/pool.c +11 -6
- data/ext/zstdruby/libzstd/common/pool.h +2 -2
- data/ext/zstdruby/libzstd/common/portability_macros.h +6 -0
- data/ext/zstdruby/libzstd/common/zstd_internal.h +3 -4
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +114 -96
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +72 -39
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +10 -10
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +38 -24
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +10 -10
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +11 -11
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +66 -62
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +5 -3
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +66 -43
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +17 -9
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +4 -1
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +2 -2
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +17 -3
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +2 -2
- data/ext/zstdruby/libzstd/zstd.h +1 -1
- data/ext/zstdruby/main.c +14 -0
- data/ext/zstdruby/streaming_compress.c +185 -0
- data/ext/zstdruby/streaming_compress.h +5 -0
- data/ext/zstdruby/streaming_decompress.c +125 -0
- data/ext/zstdruby/zstdruby.c +4 -6
- data/lib/zstd-ruby/version.rb +1 -1
- data/zstd-ruby.gemspec +1 -1
- metadata +11 -40
- data/.github/dependabot.yml +0 -8
- data/.github/workflows/ruby.yml +0 -35
- data/ext/zstdruby/libzstd/.gitignore +0 -3
- data/ext/zstdruby/libzstd/BUCK +0 -232
- data/ext/zstdruby/libzstd/Makefile +0 -357
- data/ext/zstdruby/libzstd/README.md +0 -217
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +0 -214
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +0 -26
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +0 -167
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +0 -75
- data/ext/zstdruby/libzstd/dll/example/Makefile +0 -48
- data/ext/zstdruby/libzstd/dll/example/README.md +0 -63
- data/ext/zstdruby/libzstd/dll/example/build_package.bat +0 -20
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.sln +0 -25
- data/ext/zstdruby/libzstd/dll/example/fullbench-dll.vcxproj +0 -181
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +0 -415
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +0 -2158
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +0 -94
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +0 -3518
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +0 -3160
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +0 -93
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +0 -3647
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +0 -142
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +0 -4050
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +0 -162
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +0 -4154
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +0 -172
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +0 -4541
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +0 -187
- data/ext/zstdruby/libzstd/libzstd.mk +0 -185
- data/ext/zstdruby/libzstd/libzstd.pc.in +0 -16
- data/ext/zstdruby/libzstd/modulemap/module.modulemap +0 -4
@@ -1,357 +0,0 @@
|
|
1
|
-
# ################################################################
|
2
|
-
# Copyright (c) Yann Collet, Facebook, Inc.
|
3
|
-
# All rights reserved.
|
4
|
-
#
|
5
|
-
# This source code is licensed under both the BSD-style license (found in the
|
6
|
-
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
7
|
-
# in the COPYING file in the root directory of this source tree).
|
8
|
-
# You may select, at your option, one of the above-listed licenses.
|
9
|
-
# ################################################################
|
10
|
-
|
11
|
-
# Modules
|
12
|
-
ZSTD_LIB_COMPRESSION ?= 1
|
13
|
-
ZSTD_LIB_DECOMPRESSION ?= 1
|
14
|
-
ZSTD_LIB_DICTBUILDER ?= 1
|
15
|
-
ZSTD_LIB_DEPRECATED ?= 0
|
16
|
-
|
17
|
-
# Input variables for libzstd.mk
|
18
|
-
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
|
19
|
-
ZSTD_LIB_DICTBUILDER = 0
|
20
|
-
ZSTD_LIB_DEPRECATED = 0
|
21
|
-
endif
|
22
|
-
|
23
|
-
ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
24
|
-
ZSTD_LEGACY_SUPPORT = 0
|
25
|
-
ZSTD_LIB_DEPRECATED = 0
|
26
|
-
endif
|
27
|
-
|
28
|
-
include libzstd.mk
|
29
|
-
|
30
|
-
ZSTD_FILES := $(ZSTD_COMMON_FILES) $(ZSTD_LEGACY_FILES)
|
31
|
-
|
32
|
-
ifneq ($(ZSTD_LIB_COMPRESSION), 0)
|
33
|
-
ZSTD_FILES += $(ZSTD_COMPRESS_FILES)
|
34
|
-
endif
|
35
|
-
|
36
|
-
ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
37
|
-
ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES)
|
38
|
-
endif
|
39
|
-
|
40
|
-
ifneq ($(ZSTD_LIB_DEPRECATED), 0)
|
41
|
-
ZSTD_FILES += $(ZSTD_DEPRECATED_FILES)
|
42
|
-
endif
|
43
|
-
|
44
|
-
ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
|
45
|
-
ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES)
|
46
|
-
endif
|
47
|
-
|
48
|
-
ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES))
|
49
|
-
ZSTD_LOCAL_OBJ0 := $(ZSTD_LOCAL_SRC:.c=.o)
|
50
|
-
ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_OBJ0:.S=.o)
|
51
|
-
|
52
|
-
VERSION := $(ZSTD_VERSION)
|
53
|
-
|
54
|
-
# Note: by default, the static library is built single-threaded and dynamic library is built
|
55
|
-
# multi-threaded. It is possible to force multi or single threaded builds by appending
|
56
|
-
# -mt or -nomt to the build target (like lib-mt for multi-threaded, lib-nomt for single-threaded).
|
57
|
-
.PHONY: default
|
58
|
-
default: lib-release
|
59
|
-
|
60
|
-
CPPFLAGS_DYNLIB += -DZSTD_MULTITHREAD # dynamic library build defaults to multi-threaded
|
61
|
-
LDFLAGS_DYNLIB += -pthread
|
62
|
-
CPPFLAGS_STATLIB += # static library build defaults to single-threaded
|
63
|
-
|
64
|
-
|
65
|
-
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
66
|
-
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
67
|
-
endif
|
68
|
-
|
69
|
-
|
70
|
-
# macOS linker doesn't support -soname, and use different extension
|
71
|
-
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
72
|
-
ifeq ($(UNAME), Darwin)
|
73
|
-
SHARED_EXT = dylib
|
74
|
-
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
75
|
-
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
76
|
-
SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
77
|
-
else
|
78
|
-
ifeq ($(UNAME), AIX)
|
79
|
-
SONAME_FLAGS =
|
80
|
-
else
|
81
|
-
SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
|
82
|
-
endif
|
83
|
-
SHARED_EXT = so
|
84
|
-
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
|
85
|
-
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
86
|
-
endif
|
87
|
-
|
88
|
-
|
89
|
-
.PHONY: all
|
90
|
-
all: lib
|
91
|
-
|
92
|
-
|
93
|
-
.PHONY: libzstd.a # must be run every time
|
94
|
-
libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB)
|
95
|
-
|
96
|
-
SET_CACHE_DIRECTORY = \
|
97
|
-
+$(MAKE) --no-print-directory $@ \
|
98
|
-
BUILD_DIR=obj/$(HASH_DIR) \
|
99
|
-
CPPFLAGS="$(CPPFLAGS)" \
|
100
|
-
CFLAGS="$(CFLAGS)" \
|
101
|
-
LDFLAGS="$(LDFLAGS)"
|
102
|
-
|
103
|
-
ifndef BUILD_DIR
|
104
|
-
# determine BUILD_DIR from compilation flags
|
105
|
-
|
106
|
-
libzstd.a:
|
107
|
-
$(SET_CACHE_DIRECTORY)
|
108
|
-
|
109
|
-
else
|
110
|
-
# BUILD_DIR is defined
|
111
|
-
|
112
|
-
ZSTD_STATLIB_DIR := $(BUILD_DIR)/static
|
113
|
-
ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a
|
114
|
-
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
115
|
-
$(ZSTD_STATLIB): ARFLAGS = rcs
|
116
|
-
$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR)
|
117
|
-
$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ)
|
118
|
-
# Check for multithread flag at target execution time
|
119
|
-
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
120
|
-
@echo compiling multi-threaded static library $(LIBVER),\
|
121
|
-
@echo compiling single-threaded static library $(LIBVER))
|
122
|
-
$(AR) $(ARFLAGS) $@ $^
|
123
|
-
|
124
|
-
libzstd.a: $(ZSTD_STATLIB)
|
125
|
-
cp -f $< $@
|
126
|
-
|
127
|
-
endif
|
128
|
-
|
129
|
-
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
130
|
-
|
131
|
-
LIBZSTD = dll/libzstd.dll
|
132
|
-
$(LIBZSTD): $(ZSTD_FILES)
|
133
|
-
@echo compiling dynamic library $(LIBVER)
|
134
|
-
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
|
135
|
-
|
136
|
-
else # not Windows
|
137
|
-
|
138
|
-
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
139
|
-
.PHONY: $(LIBZSTD) # must be run every time
|
140
|
-
$(LIBZSTD): CPPFLAGS += $(CPPFLAGS_DYNLIB)
|
141
|
-
$(LIBZSTD): CFLAGS += -fPIC -fvisibility=hidden
|
142
|
-
$(LIBZSTD): LDFLAGS += -shared $(LDFLAGS_DYNLIB)
|
143
|
-
|
144
|
-
ifndef BUILD_DIR
|
145
|
-
# determine BUILD_DIR from compilation flags
|
146
|
-
|
147
|
-
$(LIBZSTD):
|
148
|
-
$(SET_CACHE_DIRECTORY)
|
149
|
-
|
150
|
-
else
|
151
|
-
# BUILD_DIR is defined
|
152
|
-
|
153
|
-
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic
|
154
|
-
ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
155
|
-
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
156
|
-
|
157
|
-
$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR)
|
158
|
-
$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
159
|
-
# Check for multithread flag at target execution time
|
160
|
-
$(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\
|
161
|
-
@echo compiling multi-threaded dynamic library $(LIBVER),\
|
162
|
-
@echo compiling single-threaded dynamic library $(LIBVER))
|
163
|
-
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
164
|
-
@echo creating versioned links
|
165
|
-
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
166
|
-
ln -sf $@ libzstd.$(SHARED_EXT)
|
167
|
-
|
168
|
-
$(LIBZSTD): $(ZSTD_DYNLIB)
|
169
|
-
cp -f $< $@
|
170
|
-
|
171
|
-
endif # ifndef BUILD_DIR
|
172
|
-
endif # if windows
|
173
|
-
|
174
|
-
.PHONY: libzstd
|
175
|
-
libzstd : $(LIBZSTD)
|
176
|
-
|
177
|
-
.PHONY: lib
|
178
|
-
lib : libzstd.a libzstd
|
179
|
-
|
180
|
-
|
181
|
-
# note : do not define lib-mt or lib-release as .PHONY
|
182
|
-
# make does not consider implicit pattern rule for .PHONY target
|
183
|
-
|
184
|
-
%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD
|
185
|
-
%-mt : CPPFLAGS_STATLIB := -DZSTD_MULTITHREAD
|
186
|
-
%-mt : LDFLAGS_DYNLIB := -pthread
|
187
|
-
%-mt : %
|
188
|
-
@echo multi-threaded build completed
|
189
|
-
|
190
|
-
%-nomt : CPPFLAGS_DYNLIB :=
|
191
|
-
%-nomt : LDFLAGS_DYNLIB :=
|
192
|
-
%-nomt : CPPFLAGS_STATLIB :=
|
193
|
-
%-nomt : %
|
194
|
-
@echo single-threaded build completed
|
195
|
-
|
196
|
-
%-release : DEBUGFLAGS :=
|
197
|
-
%-release : %
|
198
|
-
@echo release build completed
|
199
|
-
|
200
|
-
|
201
|
-
# Generate .h dependencies automatically
|
202
|
-
|
203
|
-
DEPFLAGS = -MT $@ -MMD -MP -MF
|
204
|
-
|
205
|
-
$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR)
|
206
|
-
@echo CC $@
|
207
|
-
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
208
|
-
|
209
|
-
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
210
|
-
@echo CC $@
|
211
|
-
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
212
|
-
|
213
|
-
$(ZSTD_DYNLIB_DIR)/%.o : %.S | $(ZSTD_DYNLIB_DIR)
|
214
|
-
@echo AS $@
|
215
|
-
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
216
|
-
|
217
|
-
$(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR)
|
218
|
-
@echo AS $@
|
219
|
-
$(COMPILE.c) $(OUTPUT_OPTION) $<
|
220
|
-
|
221
|
-
MKDIR ?= mkdir
|
222
|
-
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
223
|
-
$(MKDIR) -p $@
|
224
|
-
|
225
|
-
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
226
|
-
$(DEPFILES):
|
227
|
-
|
228
|
-
include $(wildcard $(DEPFILES))
|
229
|
-
|
230
|
-
|
231
|
-
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
232
|
-
ZSTDMT_FILES = compress/zstdmt_compress.c
|
233
|
-
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
234
|
-
libzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden
|
235
|
-
libzstd-nomt: LDFLAGS += -shared
|
236
|
-
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
237
|
-
@echo compiling single-thread dynamic library $(LIBVER)
|
238
|
-
@echo files : $(ZSTD_NOMT_FILES)
|
239
|
-
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
240
|
-
|
241
|
-
.PHONY: clean
|
242
|
-
clean:
|
243
|
-
$(RM) -r *.dSYM # macOS-specific
|
244
|
-
$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
245
|
-
$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
246
|
-
$(RM) -r obj/*
|
247
|
-
@echo Cleaning library completed
|
248
|
-
|
249
|
-
#-----------------------------------------------------------------------------
|
250
|
-
# make install is validated only for below listed environments
|
251
|
-
#-----------------------------------------------------------------------------
|
252
|
-
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX))
|
253
|
-
|
254
|
-
lib: libzstd.pc
|
255
|
-
|
256
|
-
HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
|
257
|
-
|
258
|
-
DESTDIR ?=
|
259
|
-
# directory variables : GNU conventions prefer lowercase
|
260
|
-
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
261
|
-
# support both lower and uppercase (BSD), use uppercase in script
|
262
|
-
prefix ?= /usr/local
|
263
|
-
PREFIX ?= $(prefix)
|
264
|
-
exec_prefix ?= $(PREFIX)
|
265
|
-
EXEC_PREFIX ?= $(exec_prefix)
|
266
|
-
libdir ?= $(EXEC_PREFIX)/lib
|
267
|
-
LIBDIR ?= $(libdir)
|
268
|
-
includedir ?= $(PREFIX)/include
|
269
|
-
INCLUDEDIR ?= $(includedir)
|
270
|
-
|
271
|
-
PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
|
272
|
-
PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
|
273
|
-
|
274
|
-
# If we successfully stripped off a prefix, we'll add a reference to the
|
275
|
-
# relevant pc variable.
|
276
|
-
PCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix})
|
277
|
-
PCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix})
|
278
|
-
|
279
|
-
# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference
|
280
|
-
# to PREFIX, rather than as a resolved value.
|
281
|
-
PCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix})
|
282
|
-
|
283
|
-
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
284
|
-
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
285
|
-
else
|
286
|
-
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
287
|
-
endif
|
288
|
-
|
289
|
-
ifneq (,$(filter $(UNAME),SunOS))
|
290
|
-
INSTALL ?= ginstall
|
291
|
-
else
|
292
|
-
INSTALL ?= install
|
293
|
-
endif
|
294
|
-
|
295
|
-
INSTALL_PROGRAM ?= $(INSTALL)
|
296
|
-
INSTALL_DATA ?= $(INSTALL) -m 644
|
297
|
-
|
298
|
-
|
299
|
-
libzstd.pc: libzstd.pc.in
|
300
|
-
@echo creating pkgconfig
|
301
|
-
@sed $(SED_ERE_OPT) \
|
302
|
-
-e 's|@PREFIX@|$(PREFIX)|' \
|
303
|
-
-e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \
|
304
|
-
-e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \
|
305
|
-
-e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \
|
306
|
-
-e 's|@VERSION@|$(VERSION)|' \
|
307
|
-
-e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \
|
308
|
-
$< >$@
|
309
|
-
|
310
|
-
.PHONY: install
|
311
|
-
install: install-pc install-static install-shared install-includes
|
312
|
-
@echo zstd static and shared library installed
|
313
|
-
|
314
|
-
.PHONY: install-pc
|
315
|
-
install-pc: libzstd.pc
|
316
|
-
[ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
317
|
-
$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
318
|
-
|
319
|
-
.PHONY: install-static
|
320
|
-
install-static:
|
321
|
-
# only generate libzstd.a if it's not already present
|
322
|
-
[ -e libzstd.a ] || $(MAKE) libzstd.a-release
|
323
|
-
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
324
|
-
@echo Installing static library
|
325
|
-
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
326
|
-
|
327
|
-
.PHONY: install-shared
|
328
|
-
install-shared:
|
329
|
-
# only generate libzstd.so if it's not already present
|
330
|
-
[ -e $(LIBZSTD) ] || $(MAKE) libzstd-release
|
331
|
-
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
332
|
-
@echo Installing shared library
|
333
|
-
$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
334
|
-
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
335
|
-
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
336
|
-
|
337
|
-
.PHONY: install-includes
|
338
|
-
install-includes:
|
339
|
-
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
340
|
-
@echo Installing includes
|
341
|
-
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
342
|
-
$(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
343
|
-
$(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR)
|
344
|
-
|
345
|
-
.PHONY: uninstall
|
346
|
-
uninstall:
|
347
|
-
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
348
|
-
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
349
|
-
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
350
|
-
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
351
|
-
$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
352
|
-
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
353
|
-
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
354
|
-
$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
355
|
-
@echo zstd libraries successfully uninstalled
|
356
|
-
|
357
|
-
endif
|
@@ -1,217 +0,0 @@
|
|
1
|
-
Zstandard library files
|
2
|
-
================================
|
3
|
-
|
4
|
-
The __lib__ directory is split into several sub-directories,
|
5
|
-
in order to make it easier to select or exclude features.
|
6
|
-
|
7
|
-
|
8
|
-
#### Building
|
9
|
-
|
10
|
-
`Makefile` script is provided, supporting [Makefile conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions),
|
11
|
-
including commands variables, staged install, directory variables and standard targets.
|
12
|
-
- `make` : generates both static and dynamic libraries
|
13
|
-
- `make install` : install libraries and headers in target system directories
|
14
|
-
|
15
|
-
`libzstd` default scope is pretty large, including compression, decompression, dictionary builder,
|
16
|
-
and support for decoding legacy formats >= v0.5.0.
|
17
|
-
The scope can be reduced on demand (see paragraph _modular build_).
|
18
|
-
|
19
|
-
|
20
|
-
#### Multithreading support
|
21
|
-
|
22
|
-
When building with `make`, by default the dynamic library is multithreaded and static library is single-threaded (for compatibility reasons).
|
23
|
-
|
24
|
-
Enabling multithreading requires 2 conditions :
|
25
|
-
- set build macro `ZSTD_MULTITHREAD` (`-DZSTD_MULTITHREAD` for `gcc`)
|
26
|
-
- for POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
|
27
|
-
|
28
|
-
For convenience, we provide a build target to generate multi and single threaded libraries:
|
29
|
-
- Force enable multithreading on both dynamic and static libraries by appending `-mt` to the target, e.g. `make lib-mt`.
|
30
|
-
- Force disable multithreading on both dynamic and static libraries by appending `-nomt` to the target, e.g. `make lib-nomt`.
|
31
|
-
- By default, as mentioned before, dynamic library is multithreaded, and static library is single-threaded, e.g. `make lib`.
|
32
|
-
|
33
|
-
When linking a POSIX program with a multithreaded version of `libzstd`,
|
34
|
-
note that it's necessary to invoke the `-pthread` flag during link stage.
|
35
|
-
|
36
|
-
Multithreading capabilities are exposed
|
37
|
-
via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
|
38
|
-
|
39
|
-
|
40
|
-
#### API
|
41
|
-
|
42
|
-
Zstandard's stable API is exposed within [lib/zstd.h](zstd.h).
|
43
|
-
|
44
|
-
|
45
|
-
#### Advanced API
|
46
|
-
|
47
|
-
Optional advanced features are exposed via :
|
48
|
-
|
49
|
-
- `lib/zstd_errors.h` : translates `size_t` function results
|
50
|
-
into a `ZSTD_ErrorCode`, for accurate error handling.
|
51
|
-
|
52
|
-
- `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
|
53
|
-
it unlocks access to the experimental API,
|
54
|
-
exposed in the second part of `zstd.h`.
|
55
|
-
All definitions in the experimental APIs are unstable,
|
56
|
-
they may still change in the future, or even be removed.
|
57
|
-
As a consequence, experimental definitions shall ___never be used with dynamic library___ !
|
58
|
-
Only static linking is allowed.
|
59
|
-
|
60
|
-
|
61
|
-
#### Modular build
|
62
|
-
|
63
|
-
It's possible to compile only a limited set of features within `libzstd`.
|
64
|
-
The file structure is designed to make this selection manually achievable for any build system :
|
65
|
-
|
66
|
-
- Directory `lib/common` is always required, for all variants.
|
67
|
-
|
68
|
-
- Compression source code lies in `lib/compress`
|
69
|
-
|
70
|
-
- Decompression source code lies in `lib/decompress`
|
71
|
-
|
72
|
-
- It's possible to include only `compress` or only `decompress`, they don't depend on each other.
|
73
|
-
|
74
|
-
- `lib/dictBuilder` : makes it possible to generate dictionaries from a set of samples.
|
75
|
-
The API is exposed in `lib/dictBuilder/zdict.h`.
|
76
|
-
This module depends on both `lib/common` and `lib/compress` .
|
77
|
-
|
78
|
-
- `lib/legacy` : makes it possible to decompress legacy zstd formats, starting from `v0.1.0`.
|
79
|
-
This module depends on `lib/common` and `lib/decompress`.
|
80
|
-
To enable this feature, define `ZSTD_LEGACY_SUPPORT` during compilation.
|
81
|
-
Specifying a number limits versions supported to that version onward.
|
82
|
-
For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0".
|
83
|
-
Conversely, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats".
|
84
|
-
By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=5`.
|
85
|
-
Decoding supported legacy format is a transparent capability triggered within decompression functions.
|
86
|
-
It's also allowed to invoke legacy API directly, exposed in `lib/legacy/zstd_legacy.h`.
|
87
|
-
Each version does also provide its own set of advanced API.
|
88
|
-
For example, advanced API for version `v0.4` is exposed in `lib/legacy/zstd_v04.h` .
|
89
|
-
|
90
|
-
- While invoking `make libzstd`, it's possible to define build macros
|
91
|
-
`ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
|
92
|
-
and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
|
93
|
-
corresponding features. This will also disable compilation of all
|
94
|
-
dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
|
95
|
-
dictBuilder).
|
96
|
-
|
97
|
-
- There are a number of options that can help minimize the binary size of
|
98
|
-
`libzstd`.
|
99
|
-
|
100
|
-
The first step is to select the components needed (using the above-described
|
101
|
-
`ZSTD_LIB_COMPRESSION` etc.).
|
102
|
-
|
103
|
-
The next step is to set `ZSTD_LIB_MINIFY` to `1` when invoking `make`. This
|
104
|
-
disables various optional components and changes the compilation flags to
|
105
|
-
prioritize space-saving.
|
106
|
-
|
107
|
-
Detailed options: Zstandard's code and build environment is set up by default
|
108
|
-
to optimize above all else for performance. In pursuit of this goal, Zstandard
|
109
|
-
makes significant trade-offs in code size. For example, Zstandard often has
|
110
|
-
more than one implementation of a particular component, with each
|
111
|
-
implementation optimized for different scenarios. For example, the Huffman
|
112
|
-
decoder has complementary implementations that decode the stream one symbol at
|
113
|
-
a time or two symbols at a time. Zstd normally includes both (and dispatches
|
114
|
-
between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1` or
|
115
|
-
`HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
|
116
|
-
compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
|
117
|
-
and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
|
118
|
-
only one or the other of two decompression implementations. The smallest
|
119
|
-
binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
|
120
|
-
`ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT` (implied by `ZSTD_LIB_MINIFY`).
|
121
|
-
|
122
|
-
For squeezing the last ounce of size out, you can also define
|
123
|
-
`ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
|
124
|
-
which removes the error messages that are otherwise returned by
|
125
|
-
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
|
126
|
-
|
127
|
-
Finally, when integrating into your application, make sure you're doing link-
|
128
|
-
time optimization and unused symbol garbage collection (via some combination of,
|
129
|
-
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
|
130
|
-
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
|
131
|
-
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
|
132
|
-
the compiler's intermediate representation, e.g., `AR=gcc-ar`). Consult your
|
133
|
-
compiler's documentation.
|
134
|
-
|
135
|
-
- While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
|
136
|
-
will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
|
137
|
-
the shared library, which is now hidden by default.
|
138
|
-
|
139
|
-
- The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
|
140
|
-
which can detect at runtime the presence of BMI2 instructions, and use them only if present.
|
141
|
-
These instructions contribute to better performance, notably on the decoder side.
|
142
|
-
By default, this feature is automatically enabled on detecting
|
143
|
-
the right instruction set (x64) and compiler (clang or gcc >= 5).
|
144
|
-
It's obviously disabled for different cpus,
|
145
|
-
or when BMI2 instruction set is _required_ by the compiler command line
|
146
|
-
(in this case, only the BMI2 code path is generated).
|
147
|
-
Setting this macro will either force to generate the BMI2 dispatcher (1)
|
148
|
-
or prevent it (0). It overrides automatic detection.
|
149
|
-
|
150
|
-
- The build macro `ZSTD_NO_UNUSED_FUNCTIONS` can be defined to hide the definitions of functions
|
151
|
-
that zstd does not use. Not all unused functions are hidden, but they can be if needed.
|
152
|
-
Currently, this macro will hide function definitions in FSE and HUF that use an excessive
|
153
|
-
amount of stack space.
|
154
|
-
|
155
|
-
- The build macro `ZSTD_NO_INTRINSICS` can be defined to disable all explicit intrinsics.
|
156
|
-
Compiler builtins are still used.
|
157
|
-
|
158
|
-
- The build macro `ZSTD_DECODER_INTERNAL_BUFFER` can be set to control
|
159
|
-
the amount of extra memory used during decompression to store literals.
|
160
|
-
This defaults to 64kB. Reducing this value reduces the memory footprint of
|
161
|
-
`ZSTD_DCtx` decompression contexts,
|
162
|
-
but might also result in a small decompression speed cost.
|
163
|
-
|
164
|
-
|
165
|
-
#### Windows : using MinGW+MSYS to create DLL
|
166
|
-
|
167
|
-
DLL can be created using MinGW+MSYS with the `make libzstd` command.
|
168
|
-
This command creates `dll\libzstd.dll` and the import library `dll\libzstd.lib`.
|
169
|
-
The import library is only required with Visual C++.
|
170
|
-
The header file `zstd.h` and the dynamic library `dll\libzstd.dll` are required to
|
171
|
-
compile a project using gcc/MinGW.
|
172
|
-
The dynamic library has to be added to linking options.
|
173
|
-
It means that if a project that uses ZSTD consists of a single `test-dll.c`
|
174
|
-
file it should be linked with `dll\libzstd.dll`. For example:
|
175
|
-
```
|
176
|
-
gcc $(CFLAGS) -Iinclude/ test-dll.c -o test-dll dll\libzstd.dll
|
177
|
-
```
|
178
|
-
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
179
|
-
|
180
|
-
|
181
|
-
#### Advanced Build options
|
182
|
-
|
183
|
-
The build system requires a hash function in order to
|
184
|
-
separate object files created with different compilation flags.
|
185
|
-
By default, it tries to use `md5sum` or equivalent.
|
186
|
-
The hash function can be manually switched by setting the `HASH` variable.
|
187
|
-
For example : `make HASH=xxhsum`
|
188
|
-
The hash function needs to generate at least 64-bit using hexadecimal format.
|
189
|
-
When no hash function is found,
|
190
|
-
the Makefile just generates all object files into the same default directory,
|
191
|
-
irrespective of compilation flags.
|
192
|
-
This functionality only matters if `libzstd` is compiled multiple times
|
193
|
-
with different build flags.
|
194
|
-
|
195
|
-
The build directory, where object files are stored
|
196
|
-
can also be manually controlled using variable `BUILD_DIR`,
|
197
|
-
for example `make BUILD_DIR=objectDir/v1`.
|
198
|
-
In which case, the hash function doesn't matter.
|
199
|
-
|
200
|
-
|
201
|
-
#### Deprecated API
|
202
|
-
|
203
|
-
Obsolete API on their way out are stored in directory `lib/deprecated`.
|
204
|
-
At this stage, it contains older streaming prototypes, in `lib/deprecated/zbuff.h`.
|
205
|
-
These prototypes will be removed in some future version.
|
206
|
-
Consider migrating code towards supported streaming API exposed in `zstd.h`.
|
207
|
-
|
208
|
-
|
209
|
-
#### Miscellaneous
|
210
|
-
|
211
|
-
The other files are not source code. There are :
|
212
|
-
|
213
|
-
- `BUCK` : support for `buck` build system (https://buckbuild.com/)
|
214
|
-
- `Makefile` : `make` script to build and install zstd library (static and dynamic)
|
215
|
-
- `README.md` : this file
|
216
|
-
- `dll/` : resources directory for Windows compilation
|
217
|
-
- `libzstd.pc.in` : script for `pkg-config` (used in `make install`)
|