extzstd 0.3.1 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -14
  3. data/contrib/zstd/CHANGELOG +301 -56
  4. data/contrib/zstd/CONTRIBUTING.md +169 -72
  5. data/contrib/zstd/LICENSE +4 -4
  6. data/contrib/zstd/Makefile +116 -87
  7. data/contrib/zstd/Package.swift +36 -0
  8. data/contrib/zstd/README.md +62 -32
  9. data/contrib/zstd/TESTING.md +2 -3
  10. data/contrib/zstd/appveyor.yml +52 -136
  11. data/contrib/zstd/lib/BUCK +5 -7
  12. data/contrib/zstd/lib/Makefile +225 -222
  13. data/contrib/zstd/lib/README.md +51 -6
  14. data/contrib/zstd/lib/common/allocations.h +55 -0
  15. data/contrib/zstd/lib/common/bits.h +200 -0
  16. data/contrib/zstd/lib/common/bitstream.h +45 -62
  17. data/contrib/zstd/lib/common/compiler.h +205 -22
  18. data/contrib/zstd/lib/common/cpu.h +1 -3
  19. data/contrib/zstd/lib/common/debug.c +1 -1
  20. data/contrib/zstd/lib/common/debug.h +12 -19
  21. data/contrib/zstd/lib/common/entropy_common.c +172 -48
  22. data/contrib/zstd/lib/common/error_private.c +10 -2
  23. data/contrib/zstd/lib/common/error_private.h +82 -3
  24. data/contrib/zstd/lib/common/fse.h +37 -86
  25. data/contrib/zstd/lib/common/fse_decompress.c +117 -92
  26. data/contrib/zstd/lib/common/huf.h +99 -166
  27. data/contrib/zstd/lib/common/mem.h +124 -142
  28. data/contrib/zstd/lib/common/pool.c +54 -27
  29. data/contrib/zstd/lib/common/pool.h +10 -4
  30. data/contrib/zstd/lib/common/portability_macros.h +156 -0
  31. data/contrib/zstd/lib/common/threading.c +74 -19
  32. data/contrib/zstd/lib/common/threading.h +5 -10
  33. data/contrib/zstd/lib/common/xxhash.c +7 -847
  34. data/contrib/zstd/lib/common/xxhash.h +5568 -167
  35. data/contrib/zstd/lib/common/zstd_common.c +2 -37
  36. data/contrib/zstd/lib/common/zstd_deps.h +111 -0
  37. data/contrib/zstd/lib/common/zstd_internal.h +132 -187
  38. data/contrib/zstd/lib/common/zstd_trace.h +163 -0
  39. data/contrib/zstd/lib/compress/clevels.h +134 -0
  40. data/contrib/zstd/lib/compress/fse_compress.c +83 -157
  41. data/contrib/zstd/lib/compress/hist.c +27 -29
  42. data/contrib/zstd/lib/compress/hist.h +2 -2
  43. data/contrib/zstd/lib/compress/huf_compress.c +916 -279
  44. data/contrib/zstd/lib/compress/zstd_compress.c +3773 -1019
  45. data/contrib/zstd/lib/compress/zstd_compress_internal.h +610 -203
  46. data/contrib/zstd/lib/compress/zstd_compress_literals.c +119 -42
  47. data/contrib/zstd/lib/compress/zstd_compress_literals.h +16 -6
  48. data/contrib/zstd/lib/compress/zstd_compress_sequences.c +42 -19
  49. data/contrib/zstd/lib/compress/zstd_compress_sequences.h +1 -1
  50. data/contrib/zstd/lib/compress/zstd_compress_superblock.c +49 -317
  51. data/contrib/zstd/lib/compress/zstd_compress_superblock.h +1 -1
  52. data/contrib/zstd/lib/compress/zstd_cwksp.h +320 -103
  53. data/contrib/zstd/lib/compress/zstd_double_fast.c +388 -151
  54. data/contrib/zstd/lib/compress/zstd_double_fast.h +3 -2
  55. data/contrib/zstd/lib/compress/zstd_fast.c +729 -265
  56. data/contrib/zstd/lib/compress/zstd_fast.h +3 -2
  57. data/contrib/zstd/lib/compress/zstd_lazy.c +1270 -251
  58. data/contrib/zstd/lib/compress/zstd_lazy.h +61 -1
  59. data/contrib/zstd/lib/compress/zstd_ldm.c +324 -219
  60. data/contrib/zstd/lib/compress/zstd_ldm.h +9 -2
  61. data/contrib/zstd/lib/compress/zstd_ldm_geartab.h +106 -0
  62. data/contrib/zstd/lib/compress/zstd_opt.c +481 -209
  63. data/contrib/zstd/lib/compress/zstd_opt.h +1 -1
  64. data/contrib/zstd/lib/compress/zstdmt_compress.c +181 -457
  65. data/contrib/zstd/lib/compress/zstdmt_compress.h +34 -113
  66. data/contrib/zstd/lib/decompress/huf_decompress.c +1199 -565
  67. data/contrib/zstd/lib/decompress/huf_decompress_amd64.S +576 -0
  68. data/contrib/zstd/lib/decompress/zstd_ddict.c +12 -12
  69. data/contrib/zstd/lib/decompress/zstd_ddict.h +2 -2
  70. data/contrib/zstd/lib/decompress/zstd_decompress.c +627 -157
  71. data/contrib/zstd/lib/decompress/zstd_decompress_block.c +1086 -326
  72. data/contrib/zstd/lib/decompress/zstd_decompress_block.h +19 -5
  73. data/contrib/zstd/lib/decompress/zstd_decompress_internal.h +62 -13
  74. data/contrib/zstd/lib/deprecated/zbuff.h +1 -1
  75. data/contrib/zstd/lib/deprecated/zbuff_common.c +1 -1
  76. data/contrib/zstd/lib/deprecated/zbuff_compress.c +24 -4
  77. data/contrib/zstd/lib/deprecated/zbuff_decompress.c +3 -1
  78. data/contrib/zstd/lib/dictBuilder/cover.c +73 -52
  79. data/contrib/zstd/lib/dictBuilder/cover.h +7 -6
  80. data/contrib/zstd/lib/dictBuilder/divsufsort.c +1 -1
  81. data/contrib/zstd/lib/dictBuilder/fastcover.c +44 -35
  82. data/contrib/zstd/lib/dictBuilder/zdict.c +103 -111
  83. data/contrib/zstd/lib/legacy/zstd_legacy.h +8 -1
  84. data/contrib/zstd/lib/legacy/zstd_v01.c +21 -54
  85. data/contrib/zstd/lib/legacy/zstd_v01.h +1 -1
  86. data/contrib/zstd/lib/legacy/zstd_v02.c +29 -70
  87. data/contrib/zstd/lib/legacy/zstd_v02.h +1 -1
  88. data/contrib/zstd/lib/legacy/zstd_v03.c +30 -73
  89. data/contrib/zstd/lib/legacy/zstd_v03.h +1 -1
  90. data/contrib/zstd/lib/legacy/zstd_v04.c +29 -71
  91. data/contrib/zstd/lib/legacy/zstd_v04.h +1 -1
  92. data/contrib/zstd/lib/legacy/zstd_v05.c +40 -86
  93. data/contrib/zstd/lib/legacy/zstd_v05.h +1 -1
  94. data/contrib/zstd/lib/legacy/zstd_v06.c +47 -88
  95. data/contrib/zstd/lib/legacy/zstd_v06.h +1 -1
  96. data/contrib/zstd/lib/legacy/zstd_v07.c +40 -83
  97. data/contrib/zstd/lib/legacy/zstd_v07.h +1 -1
  98. data/contrib/zstd/lib/libzstd.mk +214 -0
  99. data/contrib/zstd/lib/libzstd.pc.in +7 -6
  100. data/contrib/zstd/lib/module.modulemap +35 -0
  101. data/contrib/zstd/lib/{dictBuilder/zdict.h → zdict.h} +203 -34
  102. data/contrib/zstd/lib/zstd.h +1217 -287
  103. data/contrib/zstd/lib/{common/zstd_errors.h → zstd_errors.h} +28 -8
  104. data/ext/extconf.rb +7 -6
  105. data/ext/extzstd.c +19 -10
  106. data/ext/extzstd.h +6 -0
  107. data/ext/libzstd_conf.h +0 -1
  108. data/ext/zstd_decompress_asm.S +1 -0
  109. data/gemstub.rb +3 -21
  110. data/lib/extzstd/version.rb +6 -1
  111. data/lib/extzstd.rb +0 -2
  112. data/test/test_basic.rb +0 -5
  113. metadata +18 -6
@@ -1,5 +1,5 @@
1
1
  # ################################################################
2
- # Copyright (c) 2015-2020, Yann Collet, Facebook, Inc.
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
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 ?= 1
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
- ZSTD_LIB_DICTBUILDER = 0
107
- ZSTD_LIB_DEPRECATED = 0
19
+ ZSTD_LIB_DICTBUILDER = 0
20
+ ZSTD_LIB_DEPRECATED = 0
108
21
  endif
109
22
 
110
23
  ifeq ($(ZSTD_LIB_DECOMPRESSION), 0)
111
- ZSTD_LEGACY_SUPPORT = 0
112
- ZSTD_LIB_DEPRECATED = 0
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
- ZSTD_FILES += $(ZSTDCOMP_FILES)
33
+ ZSTD_FILES += $(ZSTD_COMPRESS_FILES)
117
34
  endif
118
35
 
119
36
  ifneq ($(ZSTD_LIB_DECOMPRESSION), 0)
120
- ZSTD_FILES += $(ZSTDDECOMP_FILES)
37
+ ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES)
121
38
  endif
122
39
 
123
40
  ifneq ($(ZSTD_LIB_DEPRECATED), 0)
124
- ZSTD_FILES += $(ZDEPR_FILES)
41
+ ZSTD_FILES += $(ZSTD_DEPRECATED_FILES)
125
42
  endif
126
43
 
127
44
  ifneq ($(ZSTD_LIB_DICTBUILDER), 0)
128
- ZSTD_FILES += $(ZDICT_FILES)
45
+ ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES)
129
46
  endif
130
47
 
131
- ifneq ($(HUF_FORCE_DECOMPRESS_X1), 0)
132
- CFLAGS += -DHUF_FORCE_DECOMPRESS_X1
133
- endif
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
- ifneq ($(HUF_FORCE_DECOMPRESS_X2), 0)
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
- ifneq ($(ZSTD_NO_INLINE), 0)
148
- CFLAGS += -DZSTD_NO_INLINE
149
- endif
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
- ifneq ($(ZSTD_STRIP_ERROR_STRINGS), 0)
152
- CFLAGS += -DZSTD_STRIP_ERROR_STRINGS
153
- endif
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
- ifneq ($(ZSTD_LEGACY_SUPPORT), 0)
160
- ifeq ($(shell test $(ZSTD_LEGACY_SUPPORT) -lt 8; echo $$?), 0)
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 ($(shell uname), Darwin)
171
- SHARED_EXT = dylib
172
- SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
173
- SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
174
- SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
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
- SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR)
177
- SHARED_EXT = so
178
- SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
179
- SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
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: default lib-all all clean install uninstall
89
+ .PHONY: all
90
+ all: lib
91
+
184
92
 
185
- default: lib-release
93
+ .PHONY: libzstd.a # must be run every time
94
+ libzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB)
186
95
 
187
- # alias
188
- lib-all: all
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
- all: lib
103
+ ifndef BUILD_DIR
104
+ # determine BUILD_DIR from compilation flags
191
105
 
192
- libzstd.a: ARFLAGS = rcs
193
- libzstd.a: $(ZSTD_OBJ)
194
- @echo compiling static library
195
- $(Q)$(AR) $(ARFLAGS) $@ $^
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\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\libzstd.dll.a -shared $^ -o $@
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): LDFLAGS += -shared -fPIC -fvisibility=hidden
208
- $(LIBZSTD): $(ZSTD_FILES)
209
- @echo compiling dynamic library $(LIBVER)
210
- $(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
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
- $(Q)ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
213
- $(Q)ln -sf $@ libzstd.$(SHARED_EXT)
165
+ ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
166
+ ln -sf $@ libzstd.$(SHARED_EXT)
214
167
 
215
- endif
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
- .PHONY: lib-mt
224
- %-mt : CPPFLAGS += -DZSTD_MULTITHREAD
225
- %-mt : LDFLAGS += -pthread
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-threading build completed
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.S) $(OUTPUT_OPTION) $<
216
+
217
+ $(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR)
218
+ @echo AS $@
219
+ $(COMPILE.S) $(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: LDFLAGS += -shared -fPIC -fvisibility=hidden
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
- $(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
239
+ $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
243
240
 
241
+ .PHONY: clean
244
242
  clean:
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
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 $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
252
+ ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX))
253
+
254
+ lib: libzstd.pc
255
255
 
256
- all: libzstd.pc
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
- PCLIBDIR ?= $(shell echo "$(LIBDIR)" | sed -n -E -e "s@^$(EXEC_PREFIX)(/|$$)@@p")
272
- PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | sed -n -E -e "s@^$(PREFIX)(/|$$)@@p")
271
+ PCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR))
272
+ PCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR))
273
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
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
- 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
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 $(shell uname),FreeBSD NetBSD DragonFly))
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 $(shell uname),SunOS))
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
- $(Q)@sed -E -e 's|@PREFIX@|$(PREFIX)|' \
310
- -e 's|@LIBDIR@|$(PCLIBDIR)|' \
311
- -e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
312
- -e 's|@VERSION@|$(VERSION)|' \
313
- $< >$@
314
-
301
+ @sed \
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
- $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
320
- $(Q)$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
321
-
322
- install-static: libzstd.a
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
- $(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
325
- $(Q)$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
325
+ $(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
326
326
 
327
- install-shared: libzstd
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
- $(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)
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
- $(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)
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
- $(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
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
- Multithreading is disabled by default when building with `make`.
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
- Both conditions are automatically applied when invoking `make lib-mt` target.
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/common/zstd_errors.h` : translates `size_t` function results
46
- into a `ZSTD_ErrorCode`, for accurate error handling.
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,
@@ -87,7 +91,7 @@ The file structure is designed to make this selection manually achievable for an
87
91
  `ZSTD_LIB_COMPRESSION, ZSTD_LIB_DECOMPRESSION`, `ZSTD_LIB_DICTBUILDER`,
88
92
  and `ZSTD_LIB_DEPRECATED` as `0` to forgo compilation of the
89
93
  corresponding features. This will also disable compilation of all
90
- dependencies (eg. `ZSTD_LIB_COMPRESSION=0` will also disable
94
+ dependencies (e.g. `ZSTD_LIB_COMPRESSION=0` will also disable
91
95
  dictBuilder).
92
96
 
93
97
  - There are a number of options that can help minimize the binary size of
@@ -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 optimation and unused symbol garbage collection (via some combination of,
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,27 @@ 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
+
164
+ - The C compiler macros `ZSTDLIB_VISIBLE`, `ZSTDERRORLIB_VISIBLE` and `ZDICTLIB_VISIBLE`
165
+ can be overridden to control the visibility of zstd's API. Additionally,
166
+ `ZSTDLIB_STATIC_API` and `ZDICTLIB_STATIC_API` can be overridden to control the visibility
167
+ of zstd's static API. Specifically, it can be set to `ZSTDLIB_HIDDEN` to hide the symbols
168
+ from the shared library. These macros default to `ZSTDLIB_VISIBILITY`,
169
+ `ZSTDERRORLIB_VSIBILITY`, and `ZDICTLIB_VISIBILITY` if unset, for backwards compatibility
170
+ with the old macro names.
146
171
 
147
172
  #### Windows : using MinGW+MSYS to create DLL
148
173
 
@@ -160,6 +185,26 @@ file it should be linked with `dll\libzstd.dll`. For example:
160
185
  The compiled executable will require ZSTD DLL which is available at `dll\libzstd.dll`.
161
186
 
162
187
 
188
+ #### Advanced Build options
189
+
190
+ The build system requires a hash function in order to
191
+ separate object files created with different compilation flags.
192
+ By default, it tries to use `md5sum` or equivalent.
193
+ The hash function can be manually switched by setting the `HASH` variable.
194
+ For example : `make HASH=xxhsum`
195
+ The hash function needs to generate at least 64-bit using hexadecimal format.
196
+ When no hash function is found,
197
+ the Makefile just generates all object files into the same default directory,
198
+ irrespective of compilation flags.
199
+ This functionality only matters if `libzstd` is compiled multiple times
200
+ with different build flags.
201
+
202
+ The build directory, where object files are stored
203
+ can also be manually controlled using variable `BUILD_DIR`,
204
+ for example `make BUILD_DIR=objectDir/v1`.
205
+ In which case, the hash function doesn't matter.
206
+
207
+
163
208
  #### Deprecated API
164
209
 
165
210
  Obsolete API on their way out are stored in directory `lib/deprecated`.