Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/build-zstd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ CROSS=""
echo "[build-zstd] Building zstd $CLASSIFIER$CROSS with zig cc (jobs=$JOBS)..."

# Library sources: core (common/compress/decompress) plus the dictionary
# builder (ZDICT_* API). legacy/ and deprecated/ are intentionally excluded.
# builder (ZDICT_* API), plus the legacy decoders for format versions 0.4-0.7
# (matching ZSTD_LEGACY_SUPPORT=4 below — see the CFLAGS comment).
# deprecated/ (the old ZBUFF_* streaming wrapper, superseded by ZSTD_CCtx
# streaming) stays excluded — unrelated to legacy *decoding*.
# huf_decompress_amd64.S is hand-written BMI2 Huffman-decode asm; its body is
# entirely wrapped in `#if ZSTD_ENABLE_ASM_X86_64_BMI2` (gated on __x86_64__),
# so it compiles to a no-op object on every non-x86_64 target and only kicks
Expand All @@ -68,7 +71,11 @@ echo "[build-zstd] Building zstd $CLASSIFIER$CROSS with zig cc (jobs=$JOBS)..."
SRCS=$(find "$ZSTD_LIB/common" "$ZSTD_LIB/compress" "$ZSTD_LIB/decompress" \
"$ZSTD_LIB/dictBuilder" -name '*.c' | sort)
SRCS="$SRCS
$ZSTD_LIB/decompress/huf_decompress_amd64.S"
$ZSTD_LIB/decompress/huf_decompress_amd64.S
$ZSTD_LIB/legacy/zstd_v04.c
$ZSTD_LIB/legacy/zstd_v05.c
$ZSTD_LIB/legacy/zstd_v06.c
$ZSTD_LIB/legacy/zstd_v07.c"

WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT
Expand Down Expand Up @@ -103,7 +110,11 @@ case "$CLASSIFIER" in
*-aarch64) ARCH_FLAG="-mcpu=generic+crc" ;;
esac

CFLAGS="-O3 $ARCH_FLAG -DNDEBUG -DXXH_NAMESPACE=ZSTD_ $VIS_FLAG \
# Decode (not encode) formats back to zstd v0.4, matching what zstd-jni
# ships by default. v0.1-v0.3 stay off (ZSTD_LEGACY_SUPPORT>=4 skips their
# zstd_v0{1,2,3}.c decoders per legacy/zstd_legacy.h) — those predate zstd's
# 1.0 stabilization and are vanishingly unlikely to show up in the wild.
CFLAGS="-O3 $ARCH_FLAG -DNDEBUG -DZSTD_LEGACY_SUPPORT=4 -DXXH_NAMESPACE=ZSTD_ $VIS_FLAG \
-I$ZSTD_LIB -I$ZSTD_LIB/common -fPIC"

i=0
Expand Down
Loading