zstd icon indicating copy to clipboard operation
zstd copied to clipboard

[Help Wanted, Questions]How to build zstd with cmake to minimize the binary size?

Open yfaker opened this issue 1 year ago • 6 comments

Is your feature request related to a problem? Please describe.

Hi, How to minimize the binary size of libzstd when build with cmake , I've tried both cmake and make, and it turn out when I use make command ,the binary size is smallest, so how can I use cmake command to achive the same size of make does?

Here is my cmake cmd: cmake .. -DCMAKE_BUILD_WITH_INSTALL_RPATH=OFF -DCMAKE_SKIP_RPATH=ON -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_DECOMPRESSION=ON -DZSTD_BUILD_COMPRESSION=OFF -DZSTD_BUILD_DICTBUILDER=OFF -DZSTD_LEGACY_SUPPORT=OFF -DZSTD_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=./lib_install -DCMAKE_C_FLAGS=" -DHUF_FORCE_DECOMPRESS_X1 -DZSTD_FORCE_DECOMPRESS_SEQUENCES_SHORT -DZSTD_NO_INLINE -DZSTD_STRIP_ERROR_STRINGS -DZSTD_NO_UNUSED_FUNCTIONS -DZSTD_NO_INLINE -DHUF_DISABLE_FAST_DECODE -DZDICTLIB_STATIC_API" and the binary size is 102728 bytes

make cmd: make -j8 ZSTD_LIB_MINIFY=1 ZSTD_LIB_COMPRESSION=0 ZSTD_LIB_DICTBUILDER=0 ZSTD_LIB_DECOMPRESSION=1 and the binary size is 79432 bytes

Describe the solution you'd like Wonder how to build zstd with cmake to minimize the binary size,as close as possible to the size of the binary compiled with make?

Thanks a lot!

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

yfaker avatar Oct 06 '24 03:10 yfaker