Legacy default off - #4781
Merged
Merged
Legacy default off#4781
Conversation
lib/BUCK does not parse : `exported_headers=[...]` is not followed by a comma, so the whole file is a syntax error, for buck1 and buck2 alike.
.buckconfig and the VS2005 projects were left at 4 when the other build systems moved to 0, and programs/README.md still documented v0.4+ as the default. In tests/fuzz/Makefile, emit the define from $(ZSTD_LEGACY_SUPPORT) instead of hardcoding 1, so the local ?= 1 actually controls the fuzzers, which keep legacy enabled. It has to stay in FUZZ_CPPFLAGS : fuzz.py passes CPPFLAGS as a make command line variable, which overrides the `CPPFLAGS +=` from libzstd.mk. Remove the cmake include of programs/legacy, a directory that no longer exists; no program source includes a legacy header.
tests/Makefile had its own unfiltered wildcard, so the test binaries linked all 7 decoders at every level : 7 instead of 3 at level 5, and 7 instead of none at level 0 or 8, which the documented semantics treat as disabled. fuzzer, zstreamtest, fullbench and decodecorpus all carried decoders ZSTD_isLegacy() can never reach. Reuse ZSTD_LEGACY_FILES, already filtered by libzstd.mk, so tests compile exactly what the library compiles. The `legacy` target now names the full list explicitly, since it overrides the level through CPPFLAGS only. While there, test-variants.sh checked the default CLI for ZSTDv01..v04 only, which the old default of 5 already guaranteed. Check for ZSTDv0 instead, so it asserts the CLI ships no legacy decoder at all.
legacy.c only carried frames from v0.4.3 onward, so the 3 oldest decoders were never exercised by any in-tree test. Add one frame per format version, produced by the last release able to generate it (v0.1.1, v0.2.2 and v0.3.6), and make the test select at compile time the frames its ZSTD_LEGACY_SUPPORT level can decode. It therefore works at any level, instead of requiring exactly <= 4. `legacy` is now built at level 1 by default, tunable via LEGACY_TEST_LEVEL. Formats older than v0.4 have no streaming decoder, so the streaming leg skips them, mirroring ZSTD_initLegacyStream(). It gets its own frame buffer, so that each buffer keeps matching the size recorded next to it. Both APIs now also verify the decoded size, instead of reporting the mismatch and carrying on over a buffer that was never fully written.
Nothing in CI was running lib/legacy under a sanitizer since the default moved to ZSTD_LEGACY_SUPPORT=0. Add a job for it, next to the other sanitizer jobs. Also pass -Dlegacy_level=1 to the meson job : with the new default of 0, meson was silently dropping test-legacy instead of reporting anything.
:decompress pulled in :legacy, which globs all 7 decoders, while ZSTD_LEGACY_SUPPORT is 0. Both includes of zstd_legacy.h, in zstd_decompress.c and zstd_ddict.c, are guarded on that macro, so :decompress needs neither the sources nor the headers at this level. Drop the dependency, mirroring what tests/Makefile now does. Also drop the -DZSTD_LEGACY_SUPPORT=0 exported by :legacy. It is redundant with .buckconfig, and it would fight it : anyone raising the level there would have :legacy silently force 0 back onto its dependents, which is the opposite of what depending on that target is for.
Cyan4973
force-pushed
the
legacy-default-off-followup
branch
from
September 11, 2026 12:32
c5bb3c5 to
96c4d25
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Legacy decoders are now disabled by default.
They offered read support for any frame produced before the v1.0 specification.
These temporary experimental formats are now out of service for > 10 years.
This effort was already started in a previous task,
this is a follow up, that cleans up loose ends.
Legacy decoders are still tested with
asanfor robustness,but they are no longer part of the standard build,
only explicit special builds would include them.