Skip to content

build: support decoding legacy zstd formats v0.4-v0.7#73

Merged
dfa1 merged 1 commit into
mainfrom
legacy-support-70
Jul 17, 2026
Merged

build: support decoding legacy zstd formats v0.4-v0.7#73
dfa1 merged 1 commit into
mainfrom
legacy-support-70

Conversation

@dfa1

@dfa1 dfa1 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Last unchecked item from #70's checklist: DZSTD_LEGACY_SUPPORT=4 like zstd-jni.

  • Adds -DZSTD_LEGACY_SUPPORT=4 plus the four legacy decoders it requires (zstd_v04.c-zstd_v07.c), matching zstd-jni's default. v0.1-v0.3 stay off — those predate zstd's 1.0 stabilization and are essentially never encountered in practice.
  • deprecated/ (the old ZBUFF_* streaming wrapper) stays excluded — unrelated to legacy decoding, superseded by ZSTD_CCtx streaming.

Verified with real legacy-format data, not just "still links": third_party/zstd/tests/legacy.c (vendored, part of zstd's own test suite) embeds a 917-byte fixture — five concatenated frames with magic numbers 0xFD2FB524-0xFD2FB528 (v0.4 through v0.7, plus a current-format frame), each encoding the same haiku text. I extracted it and round-tripped it through a small harness linked against the built library:

  • built without this change: ZSTD_decompress fails with Unknown frame descriptor (control case, confirms the fixture actually exercises legacy decoding)
  • built with this change: decompresses all five frames correctly, byte-for-byte matching the expected text

Test plan

  • Legacy-format round-trip verified against real v0.4-v0.7 fixture data (see above) — fails without the change, passes with it
  • ./mvnw -q validate (checkstyle) clean
  • ./mvnw -q -pl zstd,integration-tests -am test passes on osx-aarch64 (no regression to current-format decode)
  • All six classifiers (osx-aarch64, osx-x86_64, linux-x86_64, linux-aarch64, windows-x86_64, windows-aarch64) cross-compile cleanly
  • CI native-build + smoke-test matrix

🤖 Generated with Claude Code

Add -DZSTD_LEGACY_SUPPORT=4 and the four legacy decoders it pulls in
(zstd_v04.c-zstd_v07.c), matching what zstd-jni ships by default.
v0.1-v0.3 stay off — those predate zstd's 1.0 stabilization and are
essentially never seen in the wild.

Verified with real legacy-format data, not just "still links": the
vendored third_party/zstd/tests/legacy.c embeds a 917-byte fixture of
five concatenated frames (magic numbers 0xFD2FB524-0xFD2FB528 - v0.4
through v0.7 plus a current-format frame), each encoding the same
haiku text. Extracted it and round-tripped through a small harness
linked against the built library:

  - built without this change: "Unknown frame descriptor" (fails, as
    expected - this is the control)
  - built with this change: decompresses all five frames correctly,
    byte-for-byte matching the expected text

deprecated/ (the old ZBUFF_* streaming wrapper) stays excluded -
unrelated to legacy decoding, superseded by ZSTD_CCtx streaming.

All six classifiers cross-compile cleanly; local unit + integration
tests pass on osx-aarch64.

Ref #70
@dfa1
dfa1 merged commit 4fa1917 into main Jul 17, 2026
1 check passed
@dfa1
dfa1 deleted the legacy-support-70 branch July 17, 2026 16:36
dfa1 added a commit that referenced this pull request Jul 18, 2026
Covers the four changes that landed from #70's investigation (#71,
#73, #75) and notes what was investigated and rejected (LTO,
x86-64-v3) with a pointer to the full benchmark data on #70.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant