Skip to content

Legacy default off - #4781

Merged
Cyan4973 merged 6 commits into
devfrom
legacy-default-off-followup
Sep 11, 2026
Merged

Cyan4973 merged 6 commits into
devfrom
legacy-default-off-followup

Conversation

@Cyan4973

Copy link
Copy Markdown
Contributor

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 asan for robustness,
but they are no longer part of the standard build,
only explicit special builds would include them.

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.
@Cyan4973 Cyan4973 self-assigned this Sep 11, 2026
@meta-cla meta-cla Bot added the CLA Signed label Sep 11, 2026
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
Cyan4973 force-pushed the legacy-default-off-followup branch from c5bb3c5 to 96c4d25 Compare September 11, 2026 12:32
@Cyan4973
Cyan4973 merged commit d79e723 into dev Sep 11, 2026
139 of 140 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant