From: Nathan Moinvaziri Date: Thu, 18 Mar 2021 06:00:44 +0000 (-0700) Subject: Added reduced memory configuration option to CMake and configure. X-Git-Tag: 2.1.0-beta1~542 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a66b109d6cf9eb518b815f016edf41302f68eaf;p=thirdparty%2Fzlib-ng.git Added reduced memory configuration option to CMake and configure. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 678f9e3e6..3ea40b502 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,6 +76,7 @@ option(ZLIB_ENABLE_TESTS "Build test binaries" ON) option(ZLIB_DUAL_LINK "Dual link tests against system zlib" OFF) option(WITH_FUZZERS "Build test/fuzz" OFF) option(WITH_OPTIM "Build with optimisation" ON) +option(WITH_REDUCED_MEM "Reduced memory usage for special cases (reduces performance)" ON) option(WITH_NEW_STRATEGIES "Use new strategies" ON) option(WITH_NATIVE_INSTRUCTIONS "Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF) @@ -109,6 +110,7 @@ option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF) mark_as_advanced(FORCE ZLIB_DUAL_LINK + WITH_REDUCED_MEM WITH_ACLE WITH_NEON WITH_DFLTCC_DEFLATE WITH_DFLTCC_INFLATE @@ -469,6 +471,13 @@ if(WITH_INFLATE_ALLOW_INVALID_DIST) add_definitions(-DINFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR) message(STATUS "Inflate zero data for invalid distances enabled") endif() +# +# Enable reduced memory configuration +# +if(WITH_REDUCED_MEM) + add_definitions(-DHASH_SIZE=32768u -DGZBUFSIZE=8192) + message(STATUS "Configured for reduced memory environment") +endif() set(ZLIB_ARCH_SRCS) diff --git a/configure b/configure index 5d58e37cd..911269254 100755 --- a/configure +++ b/configure @@ -110,6 +110,7 @@ neonflag= noltoflag="-fno-lto" without_optimizations=0 without_new_strategies=0 +reducedmem=0 gcc=0 warn=0 debug=0 @@ -154,6 +155,7 @@ case "$1" in echo ' [--without-neon] Compiles without ARM Neon SIMD instruction set' | tee -a configure.log echo ' [--with-dfltcc-deflate] Use DEFLATE CONVERSION CALL instruction for compression on IBM Z' | tee -a configure.log echo ' [--with-dfltcc-inflate] Use DEFLATE CONVERSION CALL instruction for decompression on IBM Z' | tee -a configure.log + echo ' [--with-reduced-mem] Reduced memory usage for special cases (reduces performance)' | tee -a configure.log echo ' [--force-sse2] Assume SSE2 instructions are always available (disabled by default on x86, enabled on x86_64)' | tee -a configure.log echo ' [--with-sanitizer] Build with sanitizer (memory, address, undefined)' | tee -a configure.log echo ' [--with-fuzzers] Build test/fuzz (disabled by default)' | tee -a configure.log @@ -180,6 +182,7 @@ case "$1" in --without-neon) buildneon=0; shift ;; --with-dfltcc-deflate) builddfltccdeflate=1; shift ;; --with-dfltcc-inflate) builddfltccinflate=1; shift ;; + --with-reduced-mem) reducedmem=1; shift ;; --force-sse2) forcesse2=1; shift ;; -n | --native) native=1; shift ;; -a*=* | --archs=*) ARCHS=$(echo $1 | sed 's/.*=//'); shift ;; @@ -843,6 +846,12 @@ if test $gzfileops -eq 1; then PIC_OBJC="${PIC_OBJC} \$(PIC_OBJG)" fi +# enable reduced memory configuration +if test $reducedmem -eq 1; then + echo "Configuring for reduced memory environment." | tee -a configure.log + CFLAGS="${CFLAGS} -DHASH_SIZE=32768u -DGZBUFSIZE=8192" +fi + # if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X if test $cover -eq 1; then CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"