commit: 7787a9bacbabdee07717f2af227d037f745b77bb
Author: Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 4 14:37:25 2026 +0000
Commit: Nowa Ammerlaan <nowa <AT> gentoo <DOT> org>
CommitDate: Thu Feb 5 08:08:49 2026 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7787a9ba
kernel-build.eclass: compress modules after building generic-uki
For gentoo-kernel-bin we build the gpkg with module-compression
disabled because compressing the initramfs or gpkg is less efficient
if the modules are already pre-compressed.
This however does not fix that problem for custom builds of the
generic-uki where the end goal is still to have compressed modules.
In that case we want compressed modules on the root fs but not in the
generic initrd/uki we built.
Resolve this problem by unconditionally disabling the automatic
compression of 'make modules_install' and using instead the
kernel-install_compress_modules() function from kernel-install.eclass
This has the nice side-effect of slightly simplifying the eclass and
more closely aligning the code path of gentoo-kernel-bin and
gentoo-kernel. In the future when all kernel ebuilds support
USE=generic-uki we can simplify this even further.
CONFIG_MODULE_COMPRESS_ALL is one of those options that does not
actually change anything in the kernel itself, it just toggles what the
kernel build system, and specifically make modules_install does (the
same holds for CONFIG_MODULE_COMPRESS_{GZIP,XZ,ZSTD} as well).
Therefore we can safely disable this and instead call the compressor
manually later (with the same options that make modules_install would
have called it with).
We already do precisely this in sys-kernel/gentoo-kernel-bin, we build
the gpkg with support for module compression enabled
(CONFIG_MODULE_COMPRESS=y), but without actually compressing the
modules (USE=-modules-compress and therefore
(using kernel-install_compress_modules()) then compresses the modules in
the gpkg we built depending on USE=modules-compress.
Essentially this change makes sys-kernel/gentoo-kernel do the same
thing that sys-kernel/gentoo-kernel-bin is already doing.
Signed-off-by: Nowa Ammerlaan <nowa <AT> gentoo.org>
Part-of: https://github.com/gentoo/gentoo/pull/45640
eclass/kernel-build.eclass | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 94687d1431bb..9a1eb8bbb91f 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -367,7 +367,7 @@ kernel-build_src_install() {
dostrip -x /lib/modules
local compress=()
- if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && ! use modules-compress; then
+ if [[ ${KERNEL_IUSE_GENERIC_UKI} ]]; then
compress+=(
# Workaround for <6.12, does not have
CONFIG_MODULE_COMPRESS_ALL
suffix-y=
@@ -654,6 +654,9 @@ kernel-build_src_install() {
> "${image%/*}/uki.efi" || die
fi
> "${image%/*}/initrd" || die
+
+ # If requested, compress modules *after* building generic initrd
+ kernel-install_compress_modules
fi
# unset to at least be out of the environment file in, e.g. shared
binpkgs
@@ -736,16 +739,8 @@ kernel-build_merge_configs() {
cat <<-EOF > "${WORKDIR}/module-compress.config" || die
CONFIG_MODULE_COMPRESS=y
CONFIG_MODULE_COMPRESS_XZ=y
+ # CONFIG_MODULE_COMPRESS_ALL is not set
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