mirror of
https://github.com/facebook/zstd.git
synced 2025-08-07 06:23:00 +03:00
[build] Fix ZSTD_LIB_MINIFY build option
`ZSTD_LIB_MINIFY` broke in 8bf699aa59
.
This commit fixes the macro and the static library shrinks from ~600K to 324K
with ZSTD_LIB_MINIFY set.
Fixes #3066.
This commit is contained in:
committed by
Nick Terrell
parent
358a237484
commit
0c42424a1e
14
.github/workflows/dev-short-tests.yml
vendored
14
.github/workflows/dev-short-tests.yml
vendored
@@ -236,6 +236,20 @@ jobs:
|
|||||||
# msbuild "build\VS2010\zstd.sln" /m /verbosity:minimal /property:PlatformToolset=v140
|
# msbuild "build\VS2010\zstd.sln" /m /verbosity:minimal /property:PlatformToolset=v140
|
||||||
# /t:Clean,Build /p:Platform=${{matrix.platform}} /p:Configuration=${{matrix.configuration}}
|
# /t:Clean,Build /p:Platform=${{matrix.platform}} /p:Configuration=${{matrix.configuration}}
|
||||||
|
|
||||||
|
# This tests that we don't accidently grow the size too much.
|
||||||
|
# If the size grows intentionally, you can raise these numbers.
|
||||||
|
# But we do need to think about binary size, since it is a concern.
|
||||||
|
libzstd-size:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: libzstd size test
|
||||||
|
run: |
|
||||||
|
make clean && make -j -C lib libzstd && ./tests/check_size.py lib/libzstd.so 1100000
|
||||||
|
make clean && make -j -C lib libzstd ZSTD_LIB_COMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 && ./tests/check_size.py lib/libzstd.so 400000
|
||||||
|
make clean && make -j -C lib libzstd ZSTD_LIB_MINIFY=1 && ./tests/check_size.py lib/libzstd.so 300000
|
||||||
|
make clean && make -j -C lib libzstd ZSTD_LIB_MINIFY=1 ZSTD_LIB_COMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 && ./tests/check_size.py lib/libzstd.so 80000
|
||||||
|
|
||||||
minimal-decompressor-macros:
|
minimal-decompressor-macros:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@@ -15,17 +15,34 @@
|
|||||||
# Zstd lib directory
|
# Zstd lib directory
|
||||||
LIBZSTD ?= ./
|
LIBZSTD ?= ./
|
||||||
|
|
||||||
|
# ZSTD_LIB_MINIFY is a helper variable that
|
||||||
|
# configures a bunch of other variables to space-optimized defaults.
|
||||||
|
ZSTD_LIB_MINIFY ?= 0
|
||||||
|
|
||||||
# Legacy support
|
# Legacy support
|
||||||
ZSTD_LEGACY_SUPPORT ?= 5
|
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
||||||
|
ZSTD_LEGACY_SUPPORT ?= 0
|
||||||
|
else
|
||||||
|
ZSTD_LEGACY_SUPPORT ?= 5
|
||||||
|
endif
|
||||||
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
ZSTD_LEGACY_MULTITHREADED_API ?= 0
|
||||||
|
|
||||||
# Build size optimizations
|
# Build size optimizations
|
||||||
HUF_FORCE_DECOMPRESS_X1 ?= 0
|
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
||||||
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
HUF_FORCE_DECOMPRESS_X1 ?= 1
|
||||||
ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT ?= 0
|
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
||||||
ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG ?= 0
|
ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT ?= 1
|
||||||
ZSTD_NO_INLINE ?= 0
|
ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG ?= 0
|
||||||
ZSTD_STRIP_ERROR_STRINGS ?= 0
|
ZSTD_NO_INLINE ?= 1
|
||||||
|
ZSTD_STRIP_ERROR_STRINGS ?= 1
|
||||||
|
else
|
||||||
|
HUF_FORCE_DECOMPRESS_X1 ?= 0
|
||||||
|
HUF_FORCE_DECOMPRESS_X2 ?= 0
|
||||||
|
ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT ?= 0
|
||||||
|
ZSTD_FORCE_DECOMPRESS_SEQUENCES_LONG ?= 0
|
||||||
|
ZSTD_NO_INLINE ?= 0
|
||||||
|
ZSTD_STRIP_ERROR_STRINGS ?= 0
|
||||||
|
endif
|
||||||
|
|
||||||
# Assembly support
|
# Assembly support
|
||||||
ZSTD_NO_ASM ?= 0
|
ZSTD_NO_ASM ?= 0
|
||||||
@@ -61,17 +78,8 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
|||||||
CCVER := $(shell $(CC) --version)
|
CCVER := $(shell $(CC) --version)
|
||||||
ZSTD_VERSION?= $(LIBVER)
|
ZSTD_VERSION?= $(LIBVER)
|
||||||
|
|
||||||
# ZSTD_LIB_MINIFY is a helper variable that
|
|
||||||
# configures a bunch of other variables to space-optimized defaults.
|
|
||||||
ZSTD_LIB_MINIFY ?= 0
|
|
||||||
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
||||||
HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
|
HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||||
ZSTD_LEGACY_SUPPORT ?= 0
|
|
||||||
ZSTD_LIB_DEPRECATED ?= 0
|
|
||||||
HUF_FORCE_DECOMPRESS_X1 ?= 1
|
|
||||||
ZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT ?= 1
|
|
||||||
ZSTD_NO_INLINE ?= 1
|
|
||||||
ZSTD_STRIP_ERROR_STRINGS ?= 1
|
|
||||||
ifneq ($(HAVE_CC_OZ), 0)
|
ifneq ($(HAVE_CC_OZ), 0)
|
||||||
# Some compilers (clang) support an even more space-optimized setting.
|
# Some compilers (clang) support an even more space-optimized setting.
|
||||||
CFLAGS += -Oz
|
CFLAGS += -Oz
|
||||||
|
31
tests/check_size.py
Executable file
31
tests/check_size.py
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# ################################################################
|
||||||
|
# Copyright (c) Facebook, Inc.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under both the BSD-style license (found in the
|
||||||
|
# LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
# in the COPYING file in the root directory of this source tree).
|
||||||
|
# You may select, at your option, one of the above-listed licenses.
|
||||||
|
# ################################################################
|
||||||
|
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
print(f"Usage: {sys.argv[0]} FILE SIZE_LIMIT")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
file = sys.argv[1]
|
||||||
|
limit = int(sys.argv[2])
|
||||||
|
|
||||||
|
if not os.path.exists(file):
|
||||||
|
print(f"{file} does not exist")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
size = os.path.getsize(file)
|
||||||
|
|
||||||
|
if size > limit:
|
||||||
|
print(f"file {file} is {size} bytes, which is greater than the limit of {limit} bytes")
|
||||||
|
sys.exit(1)
|
Reference in New Issue
Block a user