zstd-ruby 1.3.8.0 → 1.4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -5
  3. data/README.md +1 -1
  4. data/ext/zstdruby/libzstd/Makefile +133 -61
  5. data/ext/zstdruby/libzstd/README.md +51 -18
  6. data/ext/zstdruby/libzstd/common/bitstream.h +38 -39
  7. data/ext/zstdruby/libzstd/common/compiler.h +41 -6
  8. data/ext/zstdruby/libzstd/common/cpu.h +1 -1
  9. data/ext/zstdruby/libzstd/common/debug.c +11 -31
  10. data/ext/zstdruby/libzstd/common/debug.h +11 -31
  11. data/ext/zstdruby/libzstd/common/entropy_common.c +13 -33
  12. data/ext/zstdruby/libzstd/common/error_private.c +2 -1
  13. data/ext/zstdruby/libzstd/common/error_private.h +6 -2
  14. data/ext/zstdruby/libzstd/common/fse.h +13 -33
  15. data/ext/zstdruby/libzstd/common/fse_decompress.c +12 -35
  16. data/ext/zstdruby/libzstd/common/huf.h +15 -33
  17. data/ext/zstdruby/libzstd/common/mem.h +75 -2
  18. data/ext/zstdruby/libzstd/common/pool.c +8 -4
  19. data/ext/zstdruby/libzstd/common/pool.h +2 -2
  20. data/ext/zstdruby/libzstd/common/threading.c +52 -6
  21. data/ext/zstdruby/libzstd/common/threading.h +36 -4
  22. data/ext/zstdruby/libzstd/common/xxhash.c +25 -37
  23. data/ext/zstdruby/libzstd/common/xxhash.h +11 -31
  24. data/ext/zstdruby/libzstd/common/zstd_common.c +1 -1
  25. data/ext/zstdruby/libzstd/common/zstd_errors.h +2 -1
  26. data/ext/zstdruby/libzstd/common/zstd_internal.h +203 -22
  27. data/ext/zstdruby/libzstd/compress/fse_compress.c +19 -42
  28. data/ext/zstdruby/libzstd/compress/hist.c +15 -35
  29. data/ext/zstdruby/libzstd/compress/hist.h +12 -32
  30. data/ext/zstdruby/libzstd/compress/huf_compress.c +92 -92
  31. data/ext/zstdruby/libzstd/compress/zstd_compress.c +1460 -1472
  32. data/ext/zstdruby/libzstd/compress/zstd_compress_internal.h +330 -65
  33. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.c +158 -0
  34. data/ext/zstdruby/libzstd/compress/zstd_compress_literals.h +29 -0
  35. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.c +419 -0
  36. data/ext/zstdruby/libzstd/compress/zstd_compress_sequences.h +54 -0
  37. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.c +845 -0
  38. data/ext/zstdruby/libzstd/compress/zstd_compress_superblock.h +32 -0
  39. data/ext/zstdruby/libzstd/compress/zstd_cwksp.h +525 -0
  40. data/ext/zstdruby/libzstd/compress/zstd_double_fast.c +65 -43
  41. data/ext/zstdruby/libzstd/compress/zstd_double_fast.h +2 -2
  42. data/ext/zstdruby/libzstd/compress/zstd_fast.c +264 -159
  43. data/ext/zstdruby/libzstd/compress/zstd_fast.h +2 -2
  44. data/ext/zstdruby/libzstd/compress/zstd_lazy.c +74 -42
  45. data/ext/zstdruby/libzstd/compress/zstd_lazy.h +2 -2
  46. data/ext/zstdruby/libzstd/compress/zstd_ldm.c +33 -11
  47. data/ext/zstdruby/libzstd/compress/zstd_ldm.h +7 -2
  48. data/ext/zstdruby/libzstd/compress/zstd_opt.c +108 -125
  49. data/ext/zstdruby/libzstd/compress/zstd_opt.h +1 -1
  50. data/ext/zstdruby/libzstd/compress/zstdmt_compress.c +129 -93
  51. data/ext/zstdruby/libzstd/compress/zstdmt_compress.h +46 -28
  52. data/ext/zstdruby/libzstd/decompress/huf_decompress.c +76 -60
  53. data/ext/zstdruby/libzstd/decompress/zstd_ddict.c +14 -10
  54. data/ext/zstdruby/libzstd/decompress/zstd_ddict.h +2 -2
  55. data/ext/zstdruby/libzstd/decompress/zstd_decompress.c +471 -258
  56. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.c +471 -346
  57. data/ext/zstdruby/libzstd/decompress/zstd_decompress_block.h +3 -3
  58. data/ext/zstdruby/libzstd/decompress/zstd_decompress_internal.h +25 -4
  59. data/ext/zstdruby/libzstd/deprecated/zbuff.h +9 -8
  60. data/ext/zstdruby/libzstd/deprecated/zbuff_common.c +2 -2
  61. data/ext/zstdruby/libzstd/deprecated/zbuff_compress.c +1 -1
  62. data/ext/zstdruby/libzstd/deprecated/zbuff_decompress.c +1 -1
  63. data/ext/zstdruby/libzstd/dictBuilder/cover.c +220 -65
  64. data/ext/zstdruby/libzstd/dictBuilder/cover.h +81 -7
  65. data/ext/zstdruby/libzstd/dictBuilder/fastcover.c +85 -56
  66. data/ext/zstdruby/libzstd/dictBuilder/zdict.c +43 -19
  67. data/ext/zstdruby/libzstd/dictBuilder/zdict.h +73 -35
  68. data/ext/zstdruby/libzstd/dll/example/Makefile +2 -1
  69. data/ext/zstdruby/libzstd/dll/example/build_package.bat +3 -2
  70. data/ext/zstdruby/libzstd/legacy/zstd_legacy.h +49 -15
  71. data/ext/zstdruby/libzstd/legacy/zstd_v01.c +142 -117
  72. data/ext/zstdruby/libzstd/legacy/zstd_v01.h +13 -8
  73. data/ext/zstdruby/libzstd/legacy/zstd_v02.c +54 -25
  74. data/ext/zstdruby/libzstd/legacy/zstd_v02.h +13 -8
  75. data/ext/zstdruby/libzstd/legacy/zstd_v03.c +55 -25
  76. data/ext/zstdruby/libzstd/legacy/zstd_v03.h +13 -8
  77. data/ext/zstdruby/libzstd/legacy/zstd_v04.c +62 -29
  78. data/ext/zstdruby/libzstd/legacy/zstd_v04.h +13 -8
  79. data/ext/zstdruby/libzstd/legacy/zstd_v05.c +145 -109
  80. data/ext/zstdruby/libzstd/legacy/zstd_v05.h +14 -9
  81. data/ext/zstdruby/libzstd/legacy/zstd_v06.c +56 -26
  82. data/ext/zstdruby/libzstd/legacy/zstd_v06.h +11 -6
  83. data/ext/zstdruby/libzstd/legacy/zstd_v07.c +65 -28
  84. data/ext/zstdruby/libzstd/legacy/zstd_v07.h +11 -6
  85. data/ext/zstdruby/libzstd/libzstd.pc.in +3 -2
  86. data/ext/zstdruby/libzstd/zstd.h +921 -597
  87. data/lib/zstd-ruby/version.rb +1 -1
  88. data/zstd-ruby.gemspec +2 -2
  89. metadata +19 -14
  90. data/ext/zstdruby/libzstd/dll/libzstd.def +0 -87
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09569e18846a17f43eb0a6b5cfad3b2b2f6839e725dea1f9470ec3a12335a54f'
4
- data.tar.gz: 6f7820cc8eda43d8e0e5de6cb9f9b40dafee7a63de5f78c645bc523d67232c72
3
+ metadata.gz: 3fb9daf94529e91f7b648c1d29d5d562463553adb5d4ac420121bac1804fbeab
4
+ data.tar.gz: bdcebd2d2709f7b1c1736343846bf78c8b528237a78e45d3e7fd7c1473275ed4
5
5
  SHA512:
6
- metadata.gz: 35e224f5a80c71a84accbd6ad8973b7718bc424341edb4c9421bf4af97c9e79492e2d536ebcd940c14d2c538adf79e0e51934557764a7cc1b0c62c22d6f40a6a
7
- data.tar.gz: 2e89cc6b4ab292b72abed39fbe09dab3d3254aa5f4a92a5fdf155af325540a354ceccca7359c33f39ef8c15c44c4d2896ffb07955789f011244bc200be67f172
6
+ metadata.gz: 3e615781ba60a8525498fc5329917762411cfc4edf465ce9be06dbee5d9f08ff4bcf119142e2d61e5285f5efb94accc28d50f356d1f91cbf7d34d4531fb341f4
7
+ data.tar.gz: 87fa77e13997a63109ba65e6cf38ad429192ca62991bb600a27660762fc1381c4dfd3ea9e5561b3a17774b3e3967483a095481259bcd653aa72469c823aa929f
@@ -1,13 +1,14 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.6.0
5
- - 2.5.3
6
- - 2.4.5
7
- - 2.3.8
4
+ - 2.6
5
+ - 2.5
6
+ - 2.4
7
+ - 2.3
8
8
  - 2.2
9
9
 
10
- before_install: gem install bundler -v 1.14.3
10
+ before_install:
11
+ - gem install bundler -v 1.14.3
11
12
 
12
13
  before_script:
13
14
  - bundle exec rake compile
data/README.md CHANGED
@@ -10,7 +10,7 @@ See https://github.com/facebook/zstd
10
10
  Fork from https://github.com/jarredholman/ruby-zstd.
11
11
 
12
12
  ## Zstd version
13
- v1.3.8 (https://github.com/facebook/zstd/tree/v1.3.8)
13
+ v1.4.5 (https://github.com/facebook/zstd/tree/v1.4.5)
14
14
 
15
15
  ## Installation
16
16
 
@@ -1,12 +1,24 @@
1
1
  # ################################################################
2
- # Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
2
+ # Copyright (c) 2015-2020, 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
6
6
  # LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
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.
8
9
  # ################################################################
9
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
+
10
22
  # Version numbers
11
23
  LIBVER_MAJOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
12
24
  LIBVER_MINOR_SCRIPT:=`sed -n '/define ZSTD_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./zstd.h`
@@ -17,15 +29,15 @@ LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
17
29
  LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
18
30
  LIBVER := $(shell echo $(LIBVER_SCRIPT))
19
31
  VERSION?= $(LIBVER)
32
+ CCVER := $(shell $(CC) --version)
20
33
 
21
- CPPFLAGS+= -I. -I./common -DXXH_NAMESPACE=ZSTD_
22
- ifeq ($(OS),Windows_NT) # MinGW assumed
34
+ CPPFLAGS+= -DXXH_NAMESPACE=ZSTD_
35
+ ifeq ($(TARGET_SYSTEM),Windows_NT) # MinGW assumed
23
36
  CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
24
37
  endif
25
- CFLAGS ?= -O3
26
38
  DEBUGFLAGS= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
27
39
  -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
28
- -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
40
+ -Wstrict-prototypes -Wundef -Wpointer-arith \
29
41
  -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
30
42
  -Wredundant-decls -Wmissing-prototypes -Wc++-compat
31
43
  CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
@@ -45,11 +57,44 @@ ZDICT_FILES := $(sort $(wildcard dictBuilder/*.c))
45
57
  ZDEPR_FILES := $(sort $(wildcard deprecated/*.c))
46
58
  ZSTD_FILES := $(ZSTDCOMMON_FILES)
47
59
 
48
- ZSTD_LEGACY_SUPPORT ?= 5
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
+ # Modules
49
88
  ZSTD_LIB_COMPRESSION ?= 1
50
89
  ZSTD_LIB_DECOMPRESSION ?= 1
51
90
  ZSTD_LIB_DICTBUILDER ?= 1
52
91
  ZSTD_LIB_DEPRECATED ?= 1
92
+
93
+ # Legacy support
94
+ ZSTD_LEGACY_SUPPORT ?= 5
95
+ ZSTD_LEGACY_MULTITHREADED_API ?= 0
96
+
97
+ # Build size optimizations
53
98
  HUF_FORCE_DECOMPRESS_X1 ?= 0
54
99
  HUF_FORCE_DECOMPRESS_X2 ?= 0
55
100
  ZSTD_FORCE_DECOMPRESS_SHORT ?= 0
@@ -107,11 +152,14 @@ ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
107
152
  CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
108
153
  endif
109
154
 
155
+ ifneq ($(ZSTD_LEGACY_MULTITHREADED_API), 0)
156
+ CFLAGS += -DZSTD_LEGACY_MULTITHREADED_API
157
+ endif
158
+
110
159
  ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
111
160
  ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
112
161
  ZSTD_FILES += $(shell ls legacy/*.c | $(GREP) 'v0[$(ZSTD_LEGACY_SUPPORT)-7]')
113
162
  endif
114
- CPPFLAGS += -I./legacy
115
163
  endif
116
164
  CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
117
165
 
@@ -132,27 +180,26 @@ else
132
180
  endif
133
181
 
134
182
 
135
- .PHONY: default all clean install uninstall
183
+ .PHONY: default lib-all all clean install uninstall
136
184
 
137
185
  default: lib-release
138
186
 
187
+ # alias
188
+ lib-all: all
189
+
139
190
  all: lib
140
191
 
141
192
  libzstd.a: ARFLAGS = rcs
142
193
  libzstd.a: $(ZSTD_OBJ)
143
194
  @echo compiling static library
144
- @$(AR) $(ARFLAGS) $@ $^
145
-
146
- libzstd.a-mt: CPPFLAGS += -DZSTD_MULTITHREAD
147
- libzstd.a-mt: libzstd.a
195
+ $(Q)$(AR) $(ARFLAGS) $@ $^
148
196
 
149
- ifneq (,$(filter Windows%,$(OS)))
197
+ ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
150
198
 
151
199
  LIBZSTD = dll\libzstd.dll
152
200
  $(LIBZSTD): $(ZSTD_FILES)
153
201
  @echo compiling dynamic library $(LIBVER)
154
- @$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -shared $^ -o $@
155
- dlltool -D $@ -d dll\libzstd.def -l dll\libzstd.lib
202
+ $(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.dll.a -shared $^ -o $@
156
203
 
157
204
  else
158
205
 
@@ -160,27 +207,30 @@ LIBZSTD = libzstd.$(SHARED_EXT_VER)
160
207
  $(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
161
208
  $(LIBZSTD): $(ZSTD_FILES)
162
209
  @echo compiling dynamic library $(LIBVER)
163
- @$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
210
+ $(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
164
211
  @echo creating versioned links
165
- @ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
166
- @ln -sf $@ libzstd.$(SHARED_EXT)
212
+ $(Q)ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
213
+ $(Q)ln -sf $@ libzstd.$(SHARED_EXT)
167
214
 
168
215
  endif
169
216
 
170
-
217
+ .PHONY: libzstd
171
218
  libzstd : $(LIBZSTD)
172
219
 
173
- libzstd-mt : CPPFLAGS += -DZSTD_MULTITHREAD
174
- libzstd-mt : libzstd
220
+ .PHONY: lib
221
+ lib : libzstd.a libzstd
175
222
 
176
- lib: libzstd.a libzstd
223
+ .PHONY: lib-mt
224
+ %-mt : CPPFLAGS += -DZSTD_MULTITHREAD
225
+ %-mt : LDFLAGS += -pthread
226
+ %-mt : %
227
+ @echo multi-threading build completed
177
228
 
178
- lib-mt: CPPFLAGS += -DZSTD_MULTITHREAD
179
- lib-mt: lib
229
+ .PHONY: lib-release
230
+ %-release : DEBUGFLAGS :=
231
+ %-release : %
232
+ @echo release build completed
180
233
 
181
- lib-release lib-release-mt: DEBUGFLAGS :=
182
- lib-release: lib
183
- lib-release-mt: lib-mt
184
234
 
185
235
  # Special case : building library in single-thread mode _and_ without zstdmt_compress.c
186
236
  ZSTDMT_FILES = compress/zstdmt_compress.c
@@ -189,20 +239,22 @@ libzstd-nomt: LDFLAGS += -shared -fPIC -fvisibility=hidden
189
239
  libzstd-nomt: $(ZSTD_NOMT_FILES)
190
240
  @echo compiling single-thread dynamic library $(LIBVER)
191
241
  @echo files : $(ZSTD_NOMT_FILES)
192
- @$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
242
+ $(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
193
243
 
194
244
  clean:
195
- @$(RM) -r *.dSYM # macOS-specific
196
- @$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
197
- @$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
198
- @$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
245
+ $(Q)$(RM) -r *.dSYM # macOS-specific
246
+ $(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
247
+ $(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
248
+ $(Q)$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
199
249
  @echo Cleaning library completed
200
250
 
201
251
  #-----------------------------------------------------------------------------
202
- # make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets
252
+ # make install is validated only for below listed environments
203
253
  #-----------------------------------------------------------------------------
204
254
  ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
205
255
 
256
+ all: libzstd.pc
257
+
206
258
  DESTDIR ?=
207
259
  # directory variables : GNU conventions prefer lowercase
208
260
  # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
@@ -210,11 +262,31 @@ DESTDIR ?=
210
262
  prefix ?= /usr/local
211
263
  PREFIX ?= $(prefix)
212
264
  exec_prefix ?= $(PREFIX)
213
- libdir ?= $(exec_prefix)/lib
265
+ EXEC_PREFIX ?= $(exec_prefix)
266
+ libdir ?= $(EXEC_PREFIX)/lib
214
267
  LIBDIR ?= $(libdir)
215
268
  includedir ?= $(PREFIX)/include
216
269
  INCLUDEDIR ?= $(includedir)
217
270
 
271
+ PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -E -e "s@^$(EXEC_PREFIX)(/|$$)@@p")
272
+ PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -E -e "s@^$(PREFIX)(/|$$)@@p")
273
+
274
+ ifeq (,$(PCLIBDIR))
275
+ # Additional prefix check is required, since the empty string is technically a
276
+ # valid PCLIBDIR
277
+ ifeq (,$(shell echo "$(LIBDIR)" | sed -n -E -e "\\@^$(EXEC_PREFIX)(/|$$)@ p"))
278
+ $(error configured libdir ($(LIBDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
279
+ endif
280
+ endif
281
+
282
+ ifeq (,$(PCINCDIR))
283
+ # Additional prefix check is required, since the empty string is technically a
284
+ # valid PCINCDIR
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
289
+
218
290
  ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
219
291
  PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
220
292
  else
@@ -234,49 +306,49 @@ INSTALL_DATA ?= $(INSTALL) -m 644
234
306
  libzstd.pc:
235
307
  libzstd.pc: libzstd.pc.in
236
308
  @echo creating pkgconfig
237
- @sed -e 's|@PREFIX@|$(PREFIX)|' \
238
- -e 's|@LIBDIR@|$(LIBDIR)|' \
239
- -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
240
- -e 's|@VERSION@|$(VERSION)|' \
241
- $< >$@
309
+ $(Q)@sed -E -e 's|@PREFIX@|$(PREFIX)|' \
310
+ -e 's|@LIBDIR@|$(PCLIBDIR)|' \
311
+ -e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
312
+ -e 's|@VERSION@|$(VERSION)|' \
313
+ $< >$@
242
314
 
243
315
  install: install-pc install-static install-shared install-includes
244
316
  @echo zstd static and shared library installed
245
317
 
246
318
  install-pc: libzstd.pc
247
- @$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
248
- @$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
319
+ $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
320
+ $(Q)$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
249
321
 
250
322
  install-static: libzstd.a
251
323
  @echo Installing static library
252
- @$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
253
- @$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
324
+ $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
325
+ $(Q)$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
254
326
 
255
327
  install-shared: libzstd
256
328
  @echo Installing shared library
257
- @$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
258
- @$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
259
- @ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
260
- @ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
329
+ $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
330
+ $(Q)$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
331
+ $(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
332
+ $(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
261
333
 
262
334
  install-includes:
263
335
  @echo Installing includes
264
- @$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
265
- @$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
266
- @$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
267
- @$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
268
- @$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
336
+ $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
337
+ $(Q)$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
338
+ $(Q)$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
339
+ $(Q)$(INSTALL_DATA) deprecated/zbuff.h $(DESTDIR)$(INCLUDEDIR) # prototypes generate deprecation warnings
340
+ $(Q)$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
269
341
 
270
342
  uninstall:
271
- @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
272
- @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
273
- @$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
274
- @$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
275
- @$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
276
- @$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
277
- @$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
278
- @$(RM) $(DESTDIR)$(INCLUDEDIR)/zbuff.h # Deprecated streaming functions
279
- @$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
343
+ $(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
344
+ $(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
345
+ $(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
346
+ $(Q)$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
347
+ $(Q)$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
348
+ $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
349
+ $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
350
+ $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zbuff.h # Deprecated streaming functions
351
+ $(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
280
352
  @echo zstd libraries successfully uninstalled
281
353
 
282
354
  endif
@@ -27,12 +27,10 @@ Enabling multithreading requires 2 conditions :
27
27
  Both conditions are automatically applied when invoking `make lib-mt` target.
28
28
 
29
29
  When linking a POSIX program with a multithreaded version of `libzstd`,
30
- note that it's necessary to request the `-pthread` flag during link stage.
30
+ note that it's necessary to invoke the `-pthread` flag during link stage.
31
31
 
32
32
  Multithreading capabilities are exposed
33
- via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.3.8/lib/zstd.h#L592).
34
- This API is still labelled experimental,
35
- but is expected to become "stable" in the near future.
33
+ via the [advanced API defined in `lib/zstd.h`](https://github.com/facebook/zstd/blob/v1.4.3/lib/zstd.h#L351).
36
34
 
37
35
 
38
36
  #### API
@@ -87,28 +85,63 @@ The file structure is designed to make this selection manually achievable for an
87
85
 
88
86
  - While invoking `make libzstd`, it's possible to define build macros
89
87
  `ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
90
- and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the corresponding features.
91
- This will also disable compilation of all dependencies
92
- (eg. `ZSTD_LIB_COMPRESSION=0` will also disable dictBuilder).
93
-
94
- - There are some additional build macros that can be used to minify the decoder.
95
-
96
- Zstandard often has more than one implementation of a piece of functionality,
97
- where each implementation optimizes for different scenarios. For example, the
98
- Huffman decoder has complementary implementations that decode the stream one
99
- symbol at a time or two symbols at a time. Zstd normally includes both (and
100
- dispatches between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1`
101
- or `HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
88
+ and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
89
+ corresponding features. This will also disable compilation of all
90
+ dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
91
+ dictBuilder).
92
+
93
+ - There are a number of options that can help minimize the binary size of
94
+ `libzstd`.
95
+
96
+ The first step is to select the components needed (using the above-described
97
+ `ZSTD_LIB_COMPRESSION` etc.).
98
+
99
+ The next step is to set `ZSTD_LIB_MINIFY` to `1` when invoking `make`. This
100
+ disables various optional components and changes the compilation flags to
101
+ prioritize space-saving.
102
+
103
+ Detailed options: Zstandard's code and build environment is set up by default
104
+ to optimize above all else for performance. In pursuit of this goal, Zstandard
105
+ makes significant trade-offs in code size. For example, Zstandard often has
106
+ more than one implementation of a particular component, with each
107
+ implementation optimized for different scenarios. For example, the Huffman
108
+ decoder has complementary implementations that decode the stream one symbol at
109
+ a time or two symbols at a time. Zstd normally includes both (and dispatches
110
+ between them at runtime), but by defining `HUF_FORCE_DECOMPRESS_X1` or
111
+ `HUF_FORCE_DECOMPRESS_X2`, you can force the use of one or the other, avoiding
102
112
  compilation of the other. Similarly, `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`
103
113
  and `ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG` force the compilation and use of
104
114
  only one or the other of two decompression implementations. The smallest
105
115
  binary is achieved by using `HUF_FORCE_DECOMPRESS_X1` and
106
- `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT`.
116
+ `ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT` (implied by `ZSTD_LIB_MINIFY`).
107
117
 
108
118
  For squeezing the last ounce of size out, you can also define
109
119
  `ZSTD_NO_INLINE`, which disables inlining, and `ZSTD_STRIP_ERROR_STRINGS`,
110
120
  which removes the error messages that are otherwise returned by
111
- `ZSTD_getErrorName`.
121
+ `ZSTD_getErrorName` (implied by `ZSTD_LIB_MINIFY`).
122
+
123
+ Finally, when integrating into your application, make sure you're doing link-
124
+ time optimation and unused symbol garbage collection (via some combination of,
125
+ e.g., `-flto`, `-ffat-lto-objects`, `-fuse-linker-plugin`,
126
+ `-ffunction-sections`, `-fdata-sections`, `-fmerge-all-constants`,
127
+ `-Wl,--gc-sections`, `-Wl,-z,norelro`, and an archiver that understands
128
+ the compiler's intermediate representation, e.g., `AR=gcc-ar`). Consult your
129
+ compiler's documentation.
130
+
131
+ - While invoking `make libzstd`, the build macro `ZSTD_LEGACY_MULTITHREADED_API=1`
132
+ will expose the deprecated `ZSTDMT` API exposed by `zstdmt_compress.h` in
133
+ the shared library, which is now hidden by default.
134
+
135
+ - The build macro `DYNAMIC_BMI2` can be set to 1 or 0 in order to generate binaries
136
+ which can detect at runtime the presence of BMI2 instructions, and use them only if present.
137
+ These instructions contribute to better performance, notably on the decoder side.
138
+ By default, this feature is automatically enabled on detecting
139
+ the right instruction set (x64) and compiler (clang or gcc >= 5).
140
+ It's obviously disabled for different cpus,
141
+ or when BMI2 instruction set is _required_ by the compiler command line
142
+ (in this case, only the BMI2 code path is generated).
143
+ Setting this macro will either force to generate the BMI2 dispatcher (1)
144
+ or prevent it (0). It overrides automatic detection.
112
145
 
113
146
 
114
147
  #### Windows : using MinGW+MSYS to create DLL