From 38cce02684b5628ff1e3da5e327e565f4293558b Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 12:59:14 -0800 Subject: [PATCH 1/8] Makefile: remove support of legacy formats by default can still be changed manually by setting `ZSTD_LEGACY_SUPPORT` to a different value --- lib/libzstd.mk | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/libzstd.mk b/lib/libzstd.mk index d1744973e2c..60928b0ee95 100644 --- a/lib/libzstd.mk +++ b/lib/libzstd.mk @@ -28,12 +28,8 @@ LIB_BINDIR ?= $(LIB_SRCDIR) # configures a bunch of other variables to space-optimized defaults. ZSTD_LIB_MINIFY ?= 0 -# Legacy support -ifneq ($(ZSTD_LIB_MINIFY), 0) - ZSTD_LEGACY_SUPPORT ?= 0 -else - ZSTD_LEGACY_SUPPORT ?= 5 -endif +# Legacy support disabled by default +ZSTD_LEGACY_SUPPORT ?= 0 ZSTD_LEGACY_MULTITHREADED_API ?= 0 # Build size optimizations From b79e86291b306d6372702ed725ac600e6c6e1923 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 13:11:37 -0800 Subject: [PATCH 2/8] [cmake] disable legacy support by default can still be explicitly enabled --- build/cmake/CMakeModules/ZstdOptions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/cmake/CMakeModules/ZstdOptions.cmake b/build/cmake/CMakeModules/ZstdOptions.cmake index 3fca543a78e..dc7813444e2 100644 --- a/build/cmake/CMakeModules/ZstdOptions.cmake +++ b/build/cmake/CMakeModules/ZstdOptions.cmake @@ -2,8 +2,8 @@ # ZSTD Build Options Configuration # ################################################################ -# Legacy support configuration -option(ZSTD_LEGACY_SUPPORT "Enable legacy format support" ON) +# Legacy support configuration (disabled by default) +option(ZSTD_LEGACY_SUPPORT "Enable legacy format support" OFF) if(ZSTD_LEGACY_SUPPORT) message(STATUS "ZSTD_LEGACY_SUPPORT enabled") From 073c7fb6eaf4d121d3757d83d2433d413fe789ef Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 13:13:56 -0800 Subject: [PATCH 3/8] update dev version number to v1.6.0 to reflect the relatively big scope change by removing support of legacy formats. --- lib/zstd.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/zstd.h b/lib/zstd.h index 415474d015e..97fef316fd6 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -110,8 +110,8 @@ extern "C" { /*------ Version ------*/ #define ZSTD_VERSION_MAJOR 1 -#define ZSTD_VERSION_MINOR 5 -#define ZSTD_VERSION_RELEASE 8 +#define ZSTD_VERSION_MINOR 6 +#define ZSTD_VERSION_RELEASE 0 #define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) /*! ZSTD_versionNumber() : From 6c3e805e5061b2f800b2664ce7b09d0a4cc34f6f Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 13:19:11 -0800 Subject: [PATCH 4/8] doc: legacy support is now disabled by default --- CHANGELOG | 4 ++++ lib/README.md | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 92df0f462ee..eb46d711872 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +v1.6.0 (Dec 2025) +api: legacy format support is now disabled by default +build: `ZSTD_LEGACY_SUPPORT` defaults to `0` in Makefile and CMake + V1.5.7 (Feb 2025) fix: compression bug in 32-bit mode associated with long-lasting sessions api: new method `ZSTD_compressSequencesAndLiterals()` (#4217, #4232) diff --git a/lib/README.md b/lib/README.md index 3974de160ec..aa92bd659da 100644 --- a/lib/README.md +++ b/lib/README.md @@ -12,8 +12,9 @@ including commands variables, staged install, directory variables and standard t - `make` : generates both static and dynamic libraries - `make install` : install libraries, headers and pkg-config in local system directories -`libzstd` default scope is extensive, including compression, decompression, dictionary builder, -and support for decoding legacy formats >= v0.5.0 by default. +`libzstd` default scope includes compression, decompression, and dictionary builder. +Note: starting v1.6.0, support for decoding legacy formats is disabled by default. +See _modular build_ below to learn how to enable it. The scope can be reduced on demand (see paragraph _modular build_). #### Multiarch Support @@ -99,7 +100,7 @@ The file structure is designed to make this selection manually achievable for an Specifying a number limits versions supported to that version onward. For example, `ZSTD_LEGACY_SUPPORT=2` means : "support legacy formats >= v0.2.0". Conversely, `ZSTD_LEGACY_SUPPORT=0` means "do __not__ support legacy formats". - By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=5`. + By default, this build macro is set as `ZSTD_LEGACY_SUPPORT=0` (disabled). Decoding supported legacy format is a transparent capability triggered within decompression functions. It's also allowed to invoke legacy API directly, exposed in `lib/legacy/zstd_legacy.h`. Each version does also provide its own set of advanced API. From f818f97be64bdbd6989c80ea92b034c1965eadde Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 13:24:02 -0800 Subject: [PATCH 5/8] build: set ZSTD_LEGACY_SUPPORT=0 in remaining build systems Summary: Completes the transition to disabled legacy support by default across all build systems. This follows up on the previous Makefile and CMake changes to ensure consistent default behavior regardless of the build system used. Updated build configurations: Meson, tests/Makefile, Visual Studio 2008/2010 projects, and BUCK. Test Plan: Verified changes compile correctly via `make lib-release`. Build system configurations have been updated consistently across all platforms. --- build/VS2008/zstd/zstd.vcproj | 8 ++++---- build/VS2008/zstdlib/zstdlib.vcproj | 8 ++++---- build/VS2010/libzstd-dll/libzstd-dll.vcxproj | 8 ++++---- build/VS2010/libzstd/libzstd.vcxproj | 8 ++++---- build/VS2010/zstd/zstd.vcxproj | 8 ++++---- build/meson/meson_options.txt | 4 ++-- lib/BUCK | 2 +- tests/Makefile | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/build/VS2008/zstd/zstd.vcproj b/build/VS2008/zstd/zstd.vcproj index de1501d2056..fc87625a950 100644 --- a/build/VS2008/zstd/zstd.vcproj +++ b/build/VS2008/zstd/zstd.vcproj @@ -45,7 +45,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress" - PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -122,7 +122,7 @@ EnableIntrinsicFunctions="true" OmitFramePointers="true" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress" - PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" @@ -197,7 +197,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress" - PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -275,7 +275,7 @@ EnableIntrinsicFunctions="true" OmitFramePointers="true" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\lib\dictBuilder;$(SolutionDir)..\..\lib\compress" - PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" diff --git a/build/VS2008/zstdlib/zstdlib.vcproj b/build/VS2008/zstdlib/zstdlib.vcproj index 88c1aee26d5..61c88f5bcb4 100644 --- a/build/VS2008/zstdlib/zstdlib.vcproj +++ b/build/VS2008/zstdlib/zstdlib.vcproj @@ -45,7 +45,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\dictBuilder" - PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -121,7 +121,7 @@ EnableIntrinsicFunctions="true" OmitFramePointers="true" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\dictBuilder" - PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" @@ -195,7 +195,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\dictBuilder" - PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -272,7 +272,7 @@ EnableIntrinsicFunctions="true" OmitFramePointers="true" AdditionalIncludeDirectories="$(SolutionDir)..\..\lib;$(SolutionDir)..\..\lib\common;$(SolutionDir)..\..\lib\legacy;$(SolutionDir)..\..\programs\legacy;$(SolutionDir)..\..\lib\dictBuilder" - PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE" + PreprocessorDefinitions="ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" diff --git a/build/VS2010/libzstd-dll/libzstd-dll.vcxproj b/build/VS2010/libzstd-dll/libzstd-dll.vcxproj index 6925e0f9e58..ddb8e3216f5 100644 --- a/build/VS2010/libzstd-dll/libzstd-dll.vcxproj +++ b/build/VS2010/libzstd-dll/libzstd-dll.vcxproj @@ -169,7 +169,7 @@ Level4 Disabled - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL EditAndContinue @@ -188,7 +188,7 @@ Level4 Disabled - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -208,7 +208,7 @@ MaxSpeed true true - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false MultiThreaded ProgramDatabase @@ -229,7 +229,7 @@ MaxSpeed true true - ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_DLL_EXPORT=1;ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false false MultiThreaded diff --git a/build/VS2010/libzstd/libzstd.vcxproj b/build/VS2010/libzstd/libzstd.vcxproj index 82a2d8268fa..09ead245a64 100644 --- a/build/VS2010/libzstd/libzstd.vcxproj +++ b/build/VS2010/libzstd/libzstd.vcxproj @@ -162,7 +162,7 @@ Level4 Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL EditAndContinue @@ -181,7 +181,7 @@ Level4 Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -201,7 +201,7 @@ MaxSpeed true true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false MultiThreaded ProgramDatabase @@ -222,7 +222,7 @@ MaxSpeed true true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false false MultiThreaded diff --git a/build/VS2010/zstd/zstd.vcxproj b/build/VS2010/zstd/zstd.vcxproj index 0558687f5f6..230fd7d09e7 100644 --- a/build/VS2010/zstd/zstd.vcxproj +++ b/build/VS2010/zstd/zstd.vcxproj @@ -187,7 +187,7 @@ Level4 Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true false $(InstructionSet) @@ -204,7 +204,7 @@ Level4 Disabled - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true false $(InstructionSet) @@ -223,7 +223,7 @@ MaxSpeed true true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) false false MultiThreaded @@ -245,7 +245,7 @@ MaxSpeed true true - ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=5;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + ZSTD_MULTITHREAD=1;ZSTD_LEGACY_SUPPORT=0;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) false false MultiThreaded diff --git a/build/meson/meson_options.txt b/build/meson/meson_options.txt index 4705178279f..8d7b8856ec6 100644 --- a/build/meson/meson_options.txt +++ b/build/meson/meson_options.txt @@ -10,8 +10,8 @@ # Read guidelines from https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting -option('legacy_level', type: 'integer', min: 0, max: 7, value: 5, - description: 'Support any legacy format: 7 to 1 for v0.7+ to v0.1+') +option('legacy_level', type: 'integer', min: 0, max: 7, value: 0, + description: 'Support legacy format: 0=disabled, 1-7=support v0.1+ to v0.7+') option('debug_level', type: 'integer', min: 0, max: 9, value: 1, description: 'Enable run-time debug. See lib/common/debug.h') option('backtrace', type: 'feature', value: 'disabled', diff --git a/lib/BUCK b/lib/BUCK index 60c6bbb54d9..8c555a8be18 100644 --- a/lib/BUCK +++ b/lib/BUCK @@ -57,7 +57,7 @@ cxx_library( srcs=glob(['legacy/*.c']), deps=[':common'], exported_preprocessor_flags=[ - '-DZSTD_LEGACY_SUPPORT=4', + '-DZSTD_LEGACY_SUPPORT=0', ], ) diff --git a/tests/Makefile b/tests/Makefile index 643f8cd6119..c74c219dc7d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -20,7 +20,7 @@ # zstreamtest32: Same as zstreamtest, but forced to compile in 32-bits mode # ########################################################################## -ZSTD_LEGACY_SUPPORT ?= 5 +ZSTD_LEGACY_SUPPORT ?= 0 export ZSTD_LEGACY_SUPPORT DEBUGLEVEL ?= 2 From 8ba2f20a905386bb3524edb95335d101de9f5f66 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 13:39:28 -0800 Subject: [PATCH 6/8] test: update libzstd_builds.sh for disabled legacy default Summary: Updates the library build tests to reflect that legacy format support is now disabled by default. Also adds a new test case to verify that legacy support can still be explicitly enabled via ZSTD_LEGACY_SUPPORT=5. Test Plan: Run `bash tests/libzstd_builds.sh` on a Linux environment. --- tests/libzstd_builds.sh | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/libzstd_builds.sh b/tests/libzstd_builds.sh index f9e1e76c635..3b019c8b85f 100755 --- a/tests/libzstd_builds.sh +++ b/tests/libzstd_builds.sh @@ -21,14 +21,14 @@ mustBeAbsent() { $ECHO "$@ correctly not present" # for some reason, this $ECHO must exist, otherwise mustBeAbsent() always fails (??) } -# default compilation : all features enabled - no zbuff +# default compilation : all features enabled - no zbuff, no legacy $ECHO "testing default library compilation" CFLAGS= make -C $DIR/../lib libzstd libzstd.a > $INTOVOID nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog isPresent "zstd_compress.o" isPresent "zstd_decompress.o" isPresent "zdict.o" -isPresent "zstd_v07.o" +mustBeAbsent "zstd_v07.o" mustBeAbsent "zbuff_compress.o" $RM tmplog @@ -44,7 +44,7 @@ nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog mustBeAbsent "zstd_compress.o" isPresent "zstd_decompress.o" mustBeAbsent "zdict.o" -isPresent "zstd_v07.o" +mustBeAbsent "zstd_v07.o" mustBeAbsent "zbuff_compress.o" $RM $DIR/../lib/libzstd.a tmplog @@ -66,7 +66,7 @@ nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog isPresent "zstd_compress.o" isPresent "zstd_decompress.o" isPresent "zdict.o" -isPresent "zstd_v07.o" +mustBeAbsent "zstd_v07.o" mustBeAbsent "zbuff_compress.o" $RM $DIR/../lib/libzstd.a tmplog @@ -77,7 +77,7 @@ nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog isPresent "zstd_compress.o" isPresent "zstd_decompress.o" isPresent "zdict.o" -isPresent "zstd_v07.o" +mustBeAbsent "zstd_v07.o" isPresent "zbuff_compress.o" $RM $DIR/../lib/libzstd.a tmplog @@ -88,7 +88,7 @@ nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog isPresent "zstd_compress.o" isPresent "zstd_decompress.o" mustBeAbsent "zdict.o" -isPresent "zstd_v07.o" +mustBeAbsent "zstd_v07.o" mustBeAbsent "zbuff_compress.o" $RM $DIR/../lib/libzstd.a tmplog @@ -102,3 +102,14 @@ mustBeAbsent "zdict.o" mustBeAbsent "zstd_v07.o" mustBeAbsent "zbuff_compress.o" $RM $DIR/../lib/libzstd.a tmplog + +# legacy support explicitly enabled +$ECHO "testing with legacy support explicitly enabled" +ZSTD_LEGACY_SUPPORT=5 CFLAGS= make -C $DIR/../lib libzstd.a > $INTOVOID +nm $DIR/../lib/libzstd.a | $GREP "\.o" > tmplog +isPresent "zstd_compress.o" +isPresent "zstd_decompress.o" +isPresent "zdict.o" +isPresent "zstd_v07.o" +mustBeAbsent "zbuff_compress.o" +$RM $DIR/../lib/libzstd.a tmplog From a87d0cc476e4947ccaa5531734f7afd1c49ef766 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 13:50:56 -0800 Subject: [PATCH 7/8] test: enable legacy support in version compatibility test Summary: The version compatibility test needs to decode legacy frames (v0.5.x - v0.7.x) to verify cross-version interoperability. Since legacy support is now disabled by default (v1.6.0), head must be built with ZSTD_LEGACY_SUPPORT=5 for this test. Test Plan: Run `python3 tests/test-zstd-versions.py` to verify cross-version compatibility testing works correctly. --- tests/test-zstd-versions.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test-zstd-versions.py b/tests/test-zstd-versions.py index 1bcf39e2b25..703faa47835 100755 --- a/tests/test-zstd-versions.py +++ b/tests/test-zstd-versions.py @@ -259,13 +259,16 @@ def decompress_dict(tag): shutil.copy2('dictBuilder', '{}/dictBuilder.{}'.format(tmp_dir, tag)) os.chdir(r_dir + '/programs') # /path/to/zstd/tests/versionsTest//programs make(['clean'], False) # separate 'clean' target to allow parallel build - make(['zstd'], False) + # Enable legacy support for cross-version compatibility testing + make(['zstd', 'ZSTD_LEGACY_SUPPORT=5'], False) else: os.chdir(programs_dir) print('-----------------------------------------------') print('compiling head') print('-----------------------------------------------') - make(['zstd'], False) + # Enable legacy support for head to test cross-version compatibility + # (legacy support is disabled by default since v1.6.0) + make(['zstd', 'ZSTD_LEGACY_SUPPORT=5'], False) shutil.copy2('zstd', dst_zstd) # remove any remaining *.zst and *.dec from previous test From 1dae4f0188daff25cfef78de72627e7299a01b86 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Thu, 18 Dec 2025 15:36:07 -0800 Subject: [PATCH 8/8] test: fix versionsTest build for old zstd versions Summary: Some old zstd versions (notably v0.6.x) have a bug in fileio.c where header includes check for `ZSTD_LEGACY_SUPPORT==1` but code usage checks for `ZSTD_LEGACY_SUPPORT>=1`. Using value 5 causes compilation failure because headers aren't included but the code tries to use legacy functions. Changing to `ZSTD_LEGACY_SUPPORT=1` for old version builds fixes the compilation while still enabling legacy format support. Test Plan: Run `make versionsTest` or `python3 tests/test-zstd-versions.py` to verify all old versions compile and cross-version decompression works correctly. --- tests/test-zstd-versions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/test-zstd-versions.py b/tests/test-zstd-versions.py index 703faa47835..57131c24349 100755 --- a/tests/test-zstd-versions.py +++ b/tests/test-zstd-versions.py @@ -259,8 +259,15 @@ def decompress_dict(tag): shutil.copy2('dictBuilder', '{}/dictBuilder.{}'.format(tmp_dir, tag)) os.chdir(r_dir + '/programs') # /path/to/zstd/tests/versionsTest//programs make(['clean'], False) # separate 'clean' target to allow parallel build - # Enable legacy support for cross-version compatibility testing - make(['zstd', 'ZSTD_LEGACY_SUPPORT=5'], False) + # Enable legacy support for cross-version compatibility testing. + # Use ZSTD_LEGACY_SUPPORT=1 for v0.6.x due to a bug where headers + # check for ==1 but code checks for >=1. + # Use ZSTD_LEGACY_SUPPORT=5 for v1.2.0+ because =1 includes old + # legacy files (v01-v04) that have missing includes in newer versions. + if tag < 'v1.2.0': + make(['zstd', 'ZSTD_LEGACY_SUPPORT=1'], False) + else: + make(['zstd', 'ZSTD_LEGACY_SUPPORT=5'], False) else: os.chdir(programs_dir) print('-----------------------------------------------')