commit:     c3a527ae22dadc00ebee74a72aae5a295e26a5d5
Author:     Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
AuthorDate: Fri Dec  6 09:46:26 2024 +0000
Commit:     Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
CommitDate: Fri Dec  6 11:31:14 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c3a527ae

eclass/{dist-,}kernel{-utils,-build}.eclass: fix compression for >=6.12

Upstream commit [1] introduces several changes to the way module compression is
configured. To summarize:
- CONFIG_MODULE_COMPRESS_NONE is renamed to CONFIG_MODULE_COMPRESS and moved up,
        this (and CONFIG_MODULE_COMPRESS_<type>) control support for module
        compression.
- A new switch CONFIG_MODULE_COMPRESS_ALL is introduced to control whether the
        modules are actually compressed when running make modules_install.

This change introduced several problems that are fixed here:
- CONFIG_MODULE_COMPRESS is not implicitly enabled by setting
        CONFIG_MODULE_COMPRESS_XZ=y in the same way that 
CONFIG_MODULE_COMPRESS_NONE
        was previously implicitly disabled by enabling the xz compression. 
Fixed by
        explicitly enabling these options.
- The dist-kernel_get_module_suffix() function did not recognize the renamed
        option which caused the 'compressor not known' error in some 
configurations.
        Fixed by adding another condition to the elif statement in this 
function.

Furthermore, we now also set the switch CONFIG_MODULE_COMPRESS_ALL based on the
state of the "modules-compress" USE flag. This technically makes the "suffix-y"
override unnecessary for the >=6.12 kernels, but it does no harm so let's keep
that as it is and not add a new version conditional here.

[1] 
https://github.com/torvalds/linux/commit/c7ff693fa2094ba0a9d0a20feb4ab1658eff9c33

Signed-off-by: Nowa Ammerlaan <nowa <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/39609
Signed-off-by: Nowa Ammerlaan <nowa <AT> gentoo.org>

 eclass/dist-kernel-utils.eclass |  3 ++-
 eclass/kernel-build.eclass      | 19 ++++++++++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
index 67ba459f0ebe..210c586c8c29 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -175,7 +175,8 @@ dist-kernel_get_module_suffix() {
                echo .ko
        elif [[ ! -r ${config} ]]; then
                die "Cannot find kernel config ${config}"
-       elif grep -q "CONFIG_MODULE_COMPRESS_NONE=y" "${config}"; then
+       elif grep -q "CONFIG_MODULE_COMPRESS_NONE=y" "${config}" ||
+               grep -q "# CONFIG_MODULE_COMPRESS is not set" "${config}"; then
                echo .ko
        elif grep -q "CONFIG_MODULE_COMPRESS_GZIP=y" "${config}"; then
                echo .ko.gz

diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 376cebf3b1be..831027216321 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -371,8 +371,7 @@ kernel-build_src_install() {
        local compress=()
        if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && ! use modules-compress; then
                compress+=(
-                       # force installing uncompressed modules even if 
compression
-                       # is enabled via config
+                       # Workaround for <6.12, does not have 
CONFIG_MODULE_COMPRESS_ALL
                        suffix-y=
                )
        fi
@@ -656,12 +655,22 @@ kernel-build_merge_configs() {
 
        # Only semi-related but let's use that to avoid changing stable ebuilds.
        if [[ ${KERNEL_IUSE_GENERIC_UKI} ]]; then
-               # NB: we enable this even with USE=-modules-compress, in order
-               # to support both uncompressed and compressed modules in 
prebuilt
-               # kernels
+               # NB: we enable support for compressed modules even with
+               # USE=-modules-compress, in order to support both uncompressed 
and
+               # compressed modules in prebuilt kernels.
                cat <<-EOF > "${WORKDIR}/module-compress.config" || die
+                       CONFIG_MODULE_COMPRESS=y
                        CONFIG_MODULE_COMPRESS_XZ=y
                EOF
+               # CONFIG_MODULE_COMPRESS_ALL is supported only by >=6.12, for 
older
+               # versions we accomplish the same by overriding suffix-y=
+               if use modules-compress; then
+                       echo "CONFIG_MODULE_COMPRESS_ALL=y" \
+                               >> "${WORKDIR}/module-compress.config" || die
+               else
+                       echo "# CONFIG_MODULE_COMPRESS_ALL is not set" \
+                               >> "${WORKDIR}/module-compress.config" || die
+               fi
                merge_configs+=( "${WORKDIR}/module-compress.config" )
        fi
 

Reply via email to