]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - make.sh
make.sh: Refactor XZ compression parameters again
[ipfire-2.x.git] / make.sh
diff --git a/make.sh b/make.sh
index 5d71bab789b990a5f6721009af65fbe7613317ca..0702716584e1ad44c25bea2f4e5bb2d524c475fe 100755 (executable)
--- a/make.sh
+++ b/make.sh
@@ -225,6 +225,30 @@ configure_build() {
 
                MAKETUNING="-j${parallelism}"
        fi
+
+       # Compression parameters
+       # We use mode 8 for reasonable memory usage when decompressing
+       # but with overall good compression
+       XZ_OPT="-8"
+
+       # We try to use as many cores as possible
+       XZ_OPT="${XZ_OPT} -T0"
+
+       # We need to limit memory because XZ uses too much when running
+       # in parallel and it isn't very smart in limiting itself.
+       # We allow XZ to use up to 70% of all system memory.
+       local xz_memory=$(( HOST_MEM * 7 / 10 ))
+
+       # XZ memory cannot be larger than 2GB on 32 bit systems
+       case "${build_arch}" in
+               i*86|armv*)
+                       if [ ${xz_memory} -gt 2048 ]; then
+                               xz_memory=2048
+                       fi
+                       ;;
+       esac
+
+       XZ_OPT="${XZ_OPT} --memory=${xz_memory}MiB"
 }
 
 configure_build_guess() {
@@ -861,17 +885,6 @@ fi
 # Get the amount of memory in this build system
 HOST_MEM=$(system_memory)
 
-# Checking host memory, tuning XZ_OPT
-if [ $HOST_MEM -lt 1024 ]; then
-       print_build_stage "Host-Memory: $HOST_MEM MiB"
-       print_build_stage "Not enough host memory (less than 1024 MiB, please consider upgrading)"
-
-       exit 1
-else
-       XZ_MEM="$(( HOST_MEM * 7 / 10 ))MiB"
-       XZ_OPT="-T4 -8 --memory=$XZ_MEM"
-fi
-
 if [ -n "${BUILD_ARCH}" ]; then
        configure_build "${BUILD_ARCH}"
 else