Subject: [bug#43160] [PATCH v3 2/2] linux-libre: Enable multi-core xz compression during tarball generation.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 11 Sep 2020 10:44:59 -0400

* gnu/packages/linux.scm (make-linux-libre-source): Add an NCORES binding, and
use it to configure the number of threads xz should use via the XZ_DEFAULTS
environment variable.
---
 gnu/packages/linux.scm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 1df66330cb..d6441fa181 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -255,7 +255,8 @@ new Linux changes for nonfree code is required when skipping the comparison."
 
                 (setvbuf (current-output-port) 'line)
 
-                (let ((dir (string-append "linux-" #$version)))
+                (let ((dir (string-append "linux-" #$version))
+                      (ncores (number->string (parallel-job-count))))
 
                   (mkdir "/tmp/bin")
                   (set-path-environment-variable
@@ -289,6 +290,9 @@ new Linux changes for nonfree code is required when skipping the comparison."
                       (("/bin/sed") (which "sed"))
                       (("/usr/bin/python") (which "python"))))
 
+                  ;; This enables xz multi-core compression/decompression.
+                  (setenv "XZ_DEFAULTS" (string-append "--threads=" ncores))
+
                   (if (file-is-directory? #+linux-upstream-source)
                       (begin
                         (format #t "Copying upstream Linux source...~%")
-- 
2.28.0