zstd-ruby 1.4.5.0 → 1.5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/ruby.yml +35 -0
- data/README.md +2 -2
- data/ext/zstdruby/extconf.rb +2 -1
- data/ext/zstdruby/libzstd/BUCK +5 -7
- data/ext/zstdruby/libzstd/Makefile +225 -222
- data/ext/zstdruby/libzstd/README.md +43 -5
- data/ext/zstdruby/libzstd/common/bitstream.h +46 -22
- data/ext/zstdruby/libzstd/common/compiler.h +182 -22
- data/ext/zstdruby/libzstd/common/cpu.h +1 -3
- data/ext/zstdruby/libzstd/common/debug.c +1 -1
- data/ext/zstdruby/libzstd/common/debug.h +12 -19
- data/ext/zstdruby/libzstd/common/entropy_common.c +196 -44
- data/ext/zstdruby/libzstd/common/error_private.c +2 -1
- data/ext/zstdruby/libzstd/common/error_private.h +82 -3
- data/ext/zstdruby/libzstd/common/fse.h +41 -12
- data/ext/zstdruby/libzstd/common/fse_decompress.c +139 -22
- data/ext/zstdruby/libzstd/common/huf.h +47 -23
- data/ext/zstdruby/libzstd/common/mem.h +87 -98
- data/ext/zstdruby/libzstd/common/pool.c +23 -17
- data/ext/zstdruby/libzstd/common/pool.h +2 -2
- data/ext/zstdruby/libzstd/common/portability_macros.h +131 -0
- data/ext/zstdruby/libzstd/common/threading.c +6 -5
- data/ext/zstdruby/libzstd/common/xxhash.c +6 -846
- data/ext/zstdruby/libzstd/common/xxhash.h +5568 -167
- data/ext/zstdruby/libzstd/common/zstd_common.c +10 -10
- data/ext/zstdruby/libzstd/common/zstd_deps.h +111 -0
- data/ext/zstdruby/libzstd/common/zstd_internal.h +189 -142
- data/ext/zstdruby/libzstd/common/zstd_trace.h +163 -0
- data/ext/zstdruby/libzstd/compress/clevels.h +134 -0
- data/ext/zstdruby/libzstd/compress/fse_compress.c +89 -46
- data/ext/zstdruby/libzstd/compress/hist.c +27 -29
- data/ext/zstdruby/libzstd/compress/hist.h +2 -2
- data/ext/zstdruby/libzstd/compress/huf_compress.c +770 -198
- data/ext/zstdruby/libzstd/compress/zstd_compress.c +2894 -863
- data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +390 -90
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +12 -11
- data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +4 -2
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +31 -8
- data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +25 -297
- data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +206 -69
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +307 -132
- data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_fast.c +322 -143
- data/ext/zstdruby/libzstd/compress/zstd_fast.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstd_lazy.c +1136 -174
- data/ext/zstdruby/libzstd/compress/zstd_lazy.h +59 -1
- data/ext/zstdruby/libzstd/compress/zstd_ldm.c +316 -213
- data/ext/zstdruby/libzstd/compress/zstd_ldm.h +9 -2
- data/ext/zstdruby/libzstd/compress/zstd_ldm_geartab.h +106 -0
- data/ext/zstdruby/libzstd/compress/zstd_opt.c +373 -150
- data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +152 -444
- data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +31 -113
- data/ext/zstdruby/libzstd/decompress/huf_decompress.c +1044 -403
- data/ext/zstdruby/libzstd/decompress/huf_decompress_amd64.S +571 -0
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +9 -9
- data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
- data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +450 -105
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +913 -273
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +14 -5
- data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +59 -12
- data/ext/zstdruby/libzstd/deprecated/zbuff.h +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +1 -1
- data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +24 -4
- data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/cover.c +55 -38
- data/ext/zstdruby/libzstd/dictBuilder/cover.h +7 -6
- data/ext/zstdruby/libzstd/dictBuilder/divsufsort.c +1 -1
- data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +43 -34
- data/ext/zstdruby/libzstd/dictBuilder/zdict.c +128 -58
- data/ext/zstdruby/libzstd/dll/example/Makefile +1 -1
- data/ext/zstdruby/libzstd/dll/example/README.md +16 -22
- data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v01.c +8 -8
- data/ext/zstdruby/libzstd/legacy/zstd_v01.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v02.c +9 -9
- data/ext/zstdruby/libzstd/legacy/zstd_v02.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v03.c +9 -9
- data/ext/zstdruby/libzstd/legacy/zstd_v03.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v04.c +10 -10
- data/ext/zstdruby/libzstd/legacy/zstd_v04.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v05.c +13 -13
- data/ext/zstdruby/libzstd/legacy/zstd_v05.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v06.c +13 -13
- data/ext/zstdruby/libzstd/legacy/zstd_v06.h +1 -1
- data/ext/zstdruby/libzstd/legacy/zstd_v07.c +13 -13
- data/ext/zstdruby/libzstd/legacy/zstd_v07.h +1 -1
- data/ext/zstdruby/libzstd/libzstd.mk +185 -0
- data/ext/zstdruby/libzstd/libzstd.pc.in +4 -3
- data/ext/zstdruby/libzstd/modulemap/module.modulemap +4 -0
- data/ext/zstdruby/libzstd/{dictBuilder/zdict.h → zdict.h} +154 -7
- data/ext/zstdruby/libzstd/zstd.h +699 -214
- data/ext/zstdruby/libzstd/{common/zstd_errors.h → zstd_errors.h} +2 -1
- data/ext/zstdruby/zstdruby.c +2 -2
- data/lib/zstd-ruby/version.rb +1 -1
- metadata +15 -6
- data/.travis.yml +0 -14
@@ -1,5 +1,5 @@
|
|
1
1
|
# ################################################################
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) Yann Collet, Facebook, Inc.
|
3
3
|
# All rights reserved.
|
4
4
|
#
|
5
5
|
# This source code is licensed under both the BSD-style license (found in the
|
@@ -8,211 +8,168 @@
|
|
8
8
|
# You may select, at your option, one of the above-listed licenses.
|
9
9
|
# ################################################################
|
10
10
|
|
11
|
-
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
|
12
|
-
|
13
|
-
# When cross-compiling from linux to windows, you might
|
14
|
-
# need to specify this as "Windows." Fedora build fails
|
15
|
-
# without it.
|
16
|
-
#
|
17
|
-
# Note: mingw-w64 build from linux to windows does not
|
18
|
-
# fail on other tested distros (ubuntu, debian) even
|
19
|
-
# without manually specifying the TARGET_SYSTEM.
|
20
|
-
TARGET_SYSTEM ?= $(OS)
|
21
|
-
|
22
|
-
# Version numbers
|
23
|
-
LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
24
|
-
LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
25
|
-
LIBVER_PATCH_SCRIPT:=`sed -n '/define ZSTD_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
|
26
|
-
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
|
27
|
-
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
28
|
-
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
29
|
-
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
30
|
-
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
31
|
-
VERSION?= $(LIBVER)
|
32
|
-
CCVER := $(shell $(CC) --version)
|
33
|
-
|
34
|
-
CPPFLAGS+= -DXXH_NAMESPACE=ZSTD_
|
35
|
-
ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
|
36
|
-
CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
|
37
|
-
endif
|
38
|
-
DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
|
39
|
-
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
40
|
-
-Wstrict-prototypes -Wundef -Wpointer-arith \
|
41
|
-
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
42
|
-
-Wredundant-decls -Wmissing-prototypes -Wc++-compat
|
43
|
-
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
44
|
-
FLAGS = $(CPPFLAGS) $(CFLAGS)
|
45
|
-
|
46
|
-
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
47
|
-
GREP_OPTIONS ?=
|
48
|
-
ifeq ($HAVE_COLORNEVER, 1)
|
49
|
-
GREP_OPTIONS += --color=never
|
50
|
-
endif
|
51
|
-
GREP = grep $(GREP_OPTIONS)
|
52
|
-
|
53
|
-
ZSTDCOMMON_FILES := $(sort $(wildcard common/*.c))
|
54
|
-
ZSTDCOMP_FILES := $(sort $(wildcard compress/*.c))
|
55
|
-
ZSTDDECOMP_FILES := $(sort $(wildcard decompress/*.c))
|
56
|
-
ZDICT_FILES := $(sort $(wildcard dictBuilder/*.c))
|
57
|
-
ZDEPR_FILES := $(sort $(wildcard deprecated/*.c))
|
58
|
-
ZSTD_FILES := $(ZSTDCOMMON_FILES)
|
59
|
-
|
60
|
-
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
61
|
-
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
62
|
-
endif
|
63
|
-
|
64
|
-
# This is a helper variable that configures a bunch of other variables to new,
|
65
|
-
# space-optimized defaults.
|
66
|
-
ZSTD_LIB_MINIFY ?= 0
|
67
|
-
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
68
|
-
HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
|
69
|
-
ZSTD_LEGACY_SUPPORT ?= 0
|
70
|
-
ZSTD_LIB_DEPRECATED ?= 0
|
71
|
-
HUF_FORCE_DECOMPRESS_X1 ?= 1
|
72
|
-
ZSTD_FORCE_DECOMPRESS_SHORT ?= 1
|
73
|
-
ZSTD_NO_INLINE ?= 1
|
74
|
-
ZSTD_STRIP_ERROR_STRINGS ?= 1
|
75
|
-
ifneq ($(HAVE_CC_OZ), 0)
|
76
|
-
# Some compilers (clang) support an even more space-optimized setting.
|
77
|
-
CFLAGS += -Oz
|
78
|
-
else
|
79
|
-
CFLAGS += -Os
|
80
|
-
endif
|
81
|
-
CFLAGS += -fno-stack-protector -fomit-frame-pointer -fno-ident \
|
82
|
-
-DDYNAMIC_BMI2=0 -DNDEBUG
|
83
|
-
else
|
84
|
-
CFLAGS += -O3
|
85
|
-
endif
|
86
|
-
|
87
11
|
# Modules
|
88
12
|
ZSTD_LIB_COMPRESSION ?= 1
|
89
13
|
ZSTD_LIB_DECOMPRESSION ?= 1
|
90
14
|
ZSTD_LIB_DICTBUILDER ?= 1
|
91
|
-
ZSTD_LIB_DEPRECATED ?=
|
92
|
-
|
93
|
-
# Legacy support
|
94
|
-
ZSTD_LEGACY_SUPPORT ?= 5
|
95
|
-
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
96
|
-
|
97
|
-
# Build size optimizations
|
98
|
-
HUF_FORCE_DECOMPRESS_X1 ?= 0
|
99
|
-
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
100
|
-
ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
|
101
|
-
ZSTD_FORCE_DECOMPRESS_LONG ?= 0
|
102
|
-
ZSTD_NO_INLINE ?= 0
|
103
|
-
ZSTD_STRIP_ERROR_STRINGS ?= 0
|
15
|
+
ZSTD_LIB_DEPRECATED ?= 0
|
104
16
|
|
17
|
+
# Input variables for libzstd.mk
|
105
18
|
ifeq ($(ZSTD_LIB_COMPRESSION), 0)
|
106
|
-
|
107
|
-
|
19
|
+
ZSTD_LIB_DICTBUILDER = 0
|
20
|
+
ZSTD_LIB_DEPRECATED = 0
|
108
21
|
endif
|
109
22
|
|
110
23
|
ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
111
|
-
|
112
|
-
|
24
|
+
ZSTD_LEGACY_SUPPORT = 0
|
25
|
+
ZSTD_LIB_DEPRECATED = 0
|
113
26
|
endif
|
114
27
|
|
28
|
+
include libzstd.mk
|
29
|
+
|
30
|
+
ZSTD_FILES := $(ZSTD_COMMON_FILES) $(ZSTD_LEGACY_FILES)
|
31
|
+
|
115
32
|
ifneq ($(ZSTD_LIB_COMPRESSION), 0)
|
116
|
-
|
33
|
+
ZSTD_FILES += $(ZSTD_COMPRESS_FILES)
|
117
34
|
endif
|
118
35
|
|
119
36
|
ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
|
120
|
-
|
37
|
+
ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES)
|
121
38
|
endif
|
122
39
|
|
123
40
|
ifneq ($(ZSTD_LIB_DEPRECATED), 0)
|
124
|
-
|
41
|
+
ZSTD_FILES += $(ZSTD_DEPRECATED_FILES)
|
125
42
|
endif
|
126
43
|
|
127
44
|
ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
|
128
|
-
|
45
|
+
ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES)
|
129
46
|
endif
|
130
47
|
|
131
|
-
|
132
|
-
|
133
|
-
|
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)
|
134
51
|
|
135
|
-
|
136
|
-
CFLAGS += -DHUF_FORCE_DECOMPRESS_X2
|
137
|
-
endif
|
138
|
-
|
139
|
-
ifneq ($(ZSTD_FORCE_DECOMPRESS_SHORT), 0)
|
140
|
-
CFLAGS += -DZSTD_FORCE_DECOMPRESS_SHORT
|
141
|
-
endif
|
142
|
-
|
143
|
-
ifneq ($(ZSTD_FORCE_DECOMPRESS_LONG), 0)
|
144
|
-
CFLAGS += -DZSTD_FORCE_DECOMPRESS_LONG
|
145
|
-
endif
|
52
|
+
VERSION := $(ZSTD_VERSION)
|
146
53
|
|
147
|
-
|
148
|
-
|
149
|
-
|
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
|
150
59
|
|
151
|
-
|
152
|
-
|
153
|
-
|
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
|
154
63
|
|
155
|
-
ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
|
156
|
-
CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
|
157
|
-
endif
|
158
64
|
|
159
|
-
|
160
|
-
|
161
|
-
ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
|
162
|
-
endif
|
65
|
+
ifeq ($(findstring GCC,$(CCVER)),GCC)
|
66
|
+
decompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize
|
163
67
|
endif
|
164
|
-
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
165
68
|
|
166
|
-
ZSTD_OBJ := $(patsubst %.c,%.o,$(ZSTD_FILES))
|
167
69
|
|
168
70
|
# macOS linker doesn't support -soname, and use different extension
|
169
71
|
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
170
|
-
ifeq ($(
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
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)
|
175
77
|
else
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
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)
|
180
86
|
endif
|
181
87
|
|
182
88
|
|
183
|
-
.PHONY:
|
89
|
+
.PHONY: all
|
90
|
+
all: lib
|
91
|
+
|
184
92
|
|
185
|
-
|
93
|
+
.PHONY: libzstd.a # must be run every time
|
94
|
+
libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB)
|
186
95
|
|
187
|
-
|
188
|
-
|
96
|
+
SET_CACHE_DIRECTORY = \
|
97
|
+
+$(MAKE) --no-print-directory $@ \
|
98
|
+
BUILD_DIR=obj/$(HASH_DIR) \
|
99
|
+
CPPFLAGS="$(CPPFLAGS)" \
|
100
|
+
CFLAGS="$(CFLAGS)" \
|
101
|
+
LDFLAGS="$(LDFLAGS)"
|
189
102
|
|
190
|
-
|
103
|
+
ifndef BUILD_DIR
|
104
|
+
# determine BUILD_DIR from compilation flags
|
191
105
|
|
192
|
-
libzstd.a:
|
193
|
-
|
194
|
-
|
195
|
-
|
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
|
196
128
|
|
197
129
|
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
198
130
|
|
199
|
-
LIBZSTD = dll
|
131
|
+
LIBZSTD = dll/libzstd.dll
|
200
132
|
$(LIBZSTD): $(ZSTD_FILES)
|
201
133
|
@echo compiling dynamic library $(LIBVER)
|
202
|
-
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll
|
134
|
+
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@
|
203
135
|
|
204
|
-
else
|
136
|
+
else # not Windows
|
205
137
|
|
206
138
|
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
207
|
-
$(LIBZSTD)
|
208
|
-
$(LIBZSTD): $(
|
209
|
-
|
210
|
-
|
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 $@
|
211
164
|
@echo creating versioned links
|
212
|
-
|
213
|
-
|
165
|
+
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
166
|
+
ln -sf $@ libzstd.$(SHARED_EXT)
|
214
167
|
|
215
|
-
|
168
|
+
$(LIBZSTD): $(ZSTD_DYNLIB)
|
169
|
+
cp -f $< $@
|
170
|
+
|
171
|
+
endif # ifndef BUILD_DIR
|
172
|
+
endif # if windows
|
216
173
|
|
217
174
|
.PHONY: libzstd
|
218
175
|
libzstd : $(LIBZSTD)
|
@@ -220,40 +177,83 @@ libzstd : $(LIBZSTD)
|
|
220
177
|
.PHONY: lib
|
221
178
|
lib : libzstd.a libzstd
|
222
179
|
|
223
|
-
|
224
|
-
|
225
|
-
|
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
|
226
187
|
%-mt : %
|
227
|
-
@echo multi-
|
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
|
228
195
|
|
229
|
-
.PHONY: lib-release
|
230
196
|
%-release : DEBUGFLAGS :=
|
231
197
|
%-release : %
|
232
198
|
@echo release build completed
|
233
199
|
|
234
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
|
+
|
235
231
|
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
236
232
|
ZSTDMT_FILES = compress/zstdmt_compress.c
|
237
233
|
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
238
|
-
libzstd-nomt:
|
234
|
+
libzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden
|
235
|
+
libzstd-nomt: LDFLAGS += -shared
|
239
236
|
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
240
237
|
@echo compiling single-thread dynamic library $(LIBVER)
|
241
238
|
@echo files : $(ZSTD_NOMT_FILES)
|
242
|
-
$(
|
239
|
+
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
243
240
|
|
241
|
+
.PHONY: clean
|
244
242
|
clean:
|
245
|
-
$(
|
246
|
-
$(
|
247
|
-
$(
|
248
|
-
$(
|
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/*
|
249
247
|
@echo Cleaning library completed
|
250
248
|
|
251
249
|
#-----------------------------------------------------------------------------
|
252
250
|
# make install is validated only for below listed environments
|
253
251
|
#-----------------------------------------------------------------------------
|
254
|
-
ifneq (,$(filter $(
|
252
|
+
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX))
|
253
|
+
|
254
|
+
lib: libzstd.pc
|
255
255
|
|
256
|
-
|
256
|
+
HAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,)
|
257
257
|
|
258
258
|
DESTDIR ?=
|
259
259
|
# directory variables : GNU conventions prefer lowercase
|
@@ -268,87 +268,90 @@ LIBDIR ?= $(libdir)
|
|
268
268
|
includedir ?= $(PREFIX)/include
|
269
269
|
INCLUDEDIR ?= $(includedir)
|
270
270
|
|
271
|
-
|
272
|
-
|
271
|
+
PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
|
272
|
+
PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
|
273
273
|
|
274
|
-
|
275
|
-
#
|
276
|
-
|
277
|
-
|
278
|
-
$(error configured libdir ($(LIBDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
|
279
|
-
endif
|
280
|
-
endif
|
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})
|
281
278
|
|
282
|
-
|
283
|
-
#
|
284
|
-
|
285
|
-
ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n -E -e "\\@^$(PREFIX)(/|$$)@ p"))
|
286
|
-
$(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
|
287
|
-
endif
|
288
|
-
endif
|
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})
|
289
282
|
|
290
|
-
ifneq (,$(filter $(
|
291
|
-
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
283
|
+
ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
|
284
|
+
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
292
285
|
else
|
293
|
-
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
286
|
+
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
294
287
|
endif
|
295
288
|
|
296
|
-
ifneq (,$(filter $(
|
297
|
-
INSTALL ?= ginstall
|
289
|
+
ifneq (,$(filter $(UNAME),SunOS))
|
290
|
+
INSTALL ?= ginstall
|
298
291
|
else
|
299
|
-
INSTALL ?= install
|
292
|
+
INSTALL ?= install
|
300
293
|
endif
|
301
294
|
|
302
295
|
INSTALL_PROGRAM ?= $(INSTALL)
|
303
296
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
304
297
|
|
305
298
|
|
306
|
-
libzstd.pc:
|
307
299
|
libzstd.pc: libzstd.pc.in
|
308
300
|
@echo creating pkgconfig
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
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
|
315
311
|
install: install-pc install-static install-shared install-includes
|
316
312
|
@echo zstd static and shared library installed
|
317
313
|
|
314
|
+
.PHONY: install-pc
|
318
315
|
install-pc: libzstd.pc
|
319
|
-
$(
|
320
|
-
$(
|
321
|
-
|
322
|
-
install-static
|
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)/
|
323
324
|
@echo Installing static library
|
324
|
-
$(
|
325
|
-
$(Q)$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
325
|
+
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
326
326
|
|
327
|
-
install-shared
|
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)/
|
328
332
|
@echo Installing shared library
|
329
|
-
$(
|
330
|
-
|
331
|
-
|
332
|
-
$(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
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)
|
333
336
|
|
337
|
+
.PHONY: install-includes
|
334
338
|
install-includes:
|
339
|
+
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
335
340
|
@echo Installing includes
|
336
|
-
$(
|
337
|
-
$(
|
338
|
-
$(
|
339
|
-
$(Q)$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
|
340
|
-
$(Q)$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
|
341
|
+
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
342
|
+
$(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
343
|
+
$(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR)
|
341
344
|
|
345
|
+
.PHONY: uninstall
|
342
346
|
uninstall:
|
343
|
-
$(
|
344
|
-
$(
|
345
|
-
$(
|
346
|
-
$(
|
347
|
-
$(
|
348
|
-
$(
|
349
|
-
$(
|
350
|
-
$(
|
351
|
-
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
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
|
352
355
|
@echo zstd libraries successfully uninstalled
|
353
356
|
|
354
357
|
endif
|
@@ -19,12 +19,16 @@ The scope can be reduced on demand (see paragraph _modular build_).
|
|
19
19
|
|
20
20
|
#### Multithreading support
|
21
21
|
|
22
|
-
|
22
|
+
When building with `make`, by default the dynamic library is multithreaded and static library is single-threaded (for compatibility reasons).
|
23
|
+
|
23
24
|
Enabling multithreading requires 2 conditions :
|
24
25
|
- set build macro `ZSTD_MULTITHREAD` (`-DZSTD_MULTITHREAD` for `gcc`)
|
25
26
|
- for POSIX systems : compile with pthread (`-pthread` compilation flag for `gcc`)
|
26
27
|
|
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`.
|
28
32
|
|
29
33
|
When linking a POSIX program with a multithreaded version of `libzstd`,
|
30
34
|
note that it's necessary to invoke the `-pthread` flag during link stage.
|
@@ -42,8 +46,8 @@ Zstandard's stable API is exposed within [lib/zstd.h](zstd.h).
|
|
42
46
|
|
43
47
|
Optional advanced features are exposed via :
|
44
48
|
|
45
|
-
- `lib/
|
46
|
-
|
49
|
+
- `lib/zstd_errors.h` : translates `size_t` function results
|
50
|
+
into a `ZSTD_ErrorCode`, for accurate error handling.
|
47
51
|
|
48
52
|
- `ZSTD_STATIC_LINKING_ONLY` : if this macro is defined _before_ including `zstd.h`,
|
49
53
|
it unlocks access to the experimental API,
|
@@ -121,7 +125,7 @@ The file structure is designed to make this selection manually achievable for an
|
|
121
125
|
`ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
|
122
126
|
|
123
127
|
Finally, when integrating into your application, make sure you're doing link-
|
124
|
-
time
|
128
|
+
time optimization and unused symbol garbage collection (via some combination of,
|
125
129
|
e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
|
126
130
|
`-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
|
127
131
|
`-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
|
@@ -143,6 +147,20 @@ The file structure is designed to make this selection manually achievable for an
|
|
143
147
|
Setting this macro will either force to generate the BMI2 dispatcher (1)
|
144
148
|
or prevent it (0). It overrides automatic detection.
|
145
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
|
+
|
146
164
|
|
147
165
|
#### Windows : using MinGW+MSYS to create DLL
|
148
166
|
|
@@ -160,6 +178,26 @@ file it should be linked with `dll\libzstd.dll`. For example:
|
|
160
178
|
The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
|
161
179
|
|
162
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
|
+
|
163
201
|
#### Deprecated API
|
164
202
|
|
165
203
|
Obsolete API on their way out are stored in directory `lib/deprecated`.
|