commit:     6a47cc7bcf49b7c17fdca31969b6d6aeff84332c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 18:37:03 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 18:37:54 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=6a47cc7b

xz: add workaround for < xz 5.3.3_alpha 32-bit issue

With older versions of xz, xz -T0 will on 32-bit systems
try to allocate too much memory and bail out.

After discussing with upstream, we set --memlimit-compress=50% as a
way to make things work with both older & newer versions. This limiting
is essentially already present with >= 5.3.3_alpha as -T0 includes it.

Note that we don't need to do this for decompression as it's automatic
there for newer versions and older versions -Tn a no-op.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/ecompress                         | 2 +-
 lib/portage/util/compression_probe.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bin/ecompress b/bin/ecompress
index 977f8d7b4..e78d6931f 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -128,7 +128,7 @@ if [[ ${PORTAGE_COMPRESS_FLAGS+set} != "set" ]] ; then
                # See: https://bugs.gentoo.org/672916
                # Setting '--rm' will remove the source files after a 
successful compression.
                lz4)  PORTAGE_COMPRESS_FLAGS="-m --rm";;
-               xz)   PORTAGE_COMPRESS_FLAGS="-9 -T$(___makeopts_jobs)";;
+               xz)   PORTAGE_COMPRESS_FLAGS="-9 -T$(___makeopts_jobs) 
--memlimit-compress=50%";;
                zstd) PORTAGE_COMPRESS_FLAGS="-q --rm -T$(___makeopts_jobs)";;
        esac
 fi

diff --git a/lib/portage/util/compression_probe.py 
b/lib/portage/util/compression_probe.py
index bbff5a3c6..ddd8cf9ad 100644
--- a/lib/portage/util/compression_probe.py
+++ b/lib/portage/util/compression_probe.py
@@ -37,7 +37,7 @@ _compressors = {
         "package": "app-arch/lzop",
     },
     "xz": {
-        "compress": "xz -T{JOBS} ${BINPKG_COMPRESS_FLAGS}",
+        "compress": "xz -T{JOBS} --memlimit-compress=50% 
${BINPKG_COMPRESS_FLAGS}",
         "decompress": "xz -T{JOBS} -d",
         "package": "app-arch/xz-utils",
     },

Reply via email to