public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/4] profiles/use.desc: Add global USE=modules-compress
@ 2023-12-28 10:35 Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 2/4] kernel-{build,install}.eclass: Rename flag to modules-compress Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Górny @ 2023-12-28 10:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Michał Górny

Add a global `modules-compress` flag that controls installing compressed
kernel modules.  The primary purpose of this flag is to make it possible
to install uncompressed modules while preserving module decompression
support in the prebuilt dist-kernel.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 profiles/use.desc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/profiles/use.desc b/profiles/use.desc
index 65c809a71ddd..aa773eeb74f0 100644
--- a/profiles/use.desc
+++ b/profiles/use.desc
@@ -201,6 +201,7 @@ mms - Support for Microsoft Media Server (MMS) streams
 mng - Add support for libmng (MNG images)
 modplug - Add libmodplug support for playing SoundTracker-style music files
 modules - Build the kernel modules
+modules-compress - Install compressed kernel modules (if kernel config enables module compression)
 modules-sign - Cryptographically sign installed kernel modules (requires CONFIG_MODULE_SIG=y in the kernel)
 mono - Build Mono bindings to support dotnet type stuff
 motif - Add support for the Motif toolkit
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 2/4] kernel-{build,install}.eclass: Rename flag to modules-compress
  2023-12-28 10:35 [gentoo-dev] [PATCH 1/4] profiles/use.desc: Add global USE=modules-compress Michał Górny
@ 2023-12-28 10:35 ` Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 3/4] linux-mod-r1.eclass: Add USE=modules-compress Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 4/4] linux-mod.eclass: Fix xz compression options Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2023-12-28 10:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/kernel-build.eclass   | 4 ++--
 eclass/kernel-install.eclass | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 29ee9f86e7e2..28f111ec998b 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -284,7 +284,7 @@ kernel-build_src_install() {
 	dostrip -x /lib/modules
 
 	local compress=()
-	if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && ! use module-compress; then
+	if [[ ${KERNEL_IUSE_GENERIC_UKI} ]] && ! use modules-compress; then
 		compress+=(
 			# force installing uncompressed modules even if compression
 			# is enabled via config
@@ -560,7 +560,7 @@ 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=-module-compress, in order
+		# NB: we enable this even with USE=-modules-compress, in order
 		# to support both uncompressed and compressed modules in prebuilt
 		# kernels
 		cat <<-EOF > "${WORKDIR}/module-compress.config" || die
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index 8c4d5c14fc03..af4f5d839b0e 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -79,7 +79,7 @@ _IDEPEND_BASE="
 
 LICENSE="GPL-2"
 if [[ ${KERNEL_IUSE_GENERIC_UKI} ]]; then
-	IUSE+=" generic-uki module-compress"
+	IUSE+=" generic-uki modules-compress"
 	# https://github.com/AndrewAmmerlaan/dist-kernel-log-to-licenses
 	# This script can help with generating the array below, keep in mind
 	# that it is not a fully automatic solution, i.e. use flags will
@@ -762,11 +762,11 @@ kernel-install_pkg_config() {
 
 # @FUNCTION: kernel-install_compress_modules
 # @DESCRIPTION:
-# Compress modules installed in ED, if USE=module-compress is enabled.
+# Compress modules installed in ED, if USE=modules-compress is enabled.
 kernel-install_compress_modules() {
 	debug-print-function ${FUNCNAME} "${@}"
 
-	if use module-compress; then
+	if use modules-compress; then
 		einfo "Compressing kernel modules ..."
 		# taken from scripts/Makefile.modinst
 		find "${ED}/lib" -name '*.ko' -exec \
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 3/4] linux-mod-r1.eclass: Add USE=modules-compress
  2023-12-28 10:35 [gentoo-dev] [PATCH 1/4] profiles/use.desc: Add global USE=modules-compress Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 2/4] kernel-{build,install}.eclass: Rename flag to modules-compress Michał Górny
@ 2023-12-28 10:35 ` Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 4/4] linux-mod.eclass: Fix xz compression options Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2023-12-28 10:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Michał Górny

Add a `modules-compress` USE flag to explicitly control kernel module
compression.  When the flag is disabled, modules are installed
uncompressed even if the kernel supports compression (which is going
to be the case for new sys-kernel/gentoo-kernel* builds).  When it is
enabled, the eclass compresses modules using the compressor configured,
or fails if no compression is supported.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/linux-mod-r1.eclass | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/eclass/linux-mod-r1.eclass b/eclass/linux-mod-r1.eclass
index 44fc927c3a70..54df2406e5c7 100644
--- a/eclass/linux-mod-r1.eclass
+++ b/eclass/linux-mod-r1.eclass
@@ -111,7 +111,7 @@ _LINUX_MOD_R1_ECLASS=1
 
 inherit edo linux-info multiprocessing toolchain-funcs
 
-IUSE="dist-kernel modules-sign +strip ${MODULES_OPTIONAL_IUSE}"
+IUSE="dist-kernel modules-compress modules-sign +strip ${MODULES_OPTIONAL_IUSE}"
 
 RDEPEND="
 	sys-apps/kmod[tools]
@@ -835,6 +835,8 @@ _modules_prepare_toolchain() {
 # If enabled in the kernel configuration, this compresses the given
 # modules using the same format.
 _modules_process_compress() {
+	use modules-compress || return
+
 	local -a compress
 	if linux_chkconfig_present MODULE_COMPRESS_XZ; then
 		compress=(
@@ -853,13 +855,13 @@ _modules_process_compress() {
 		fi
 	elif linux_chkconfig_present MODULE_COMPRESS_ZSTD; then
 		compress=(zstd -qT"$(makeopts_jobs)" --rm)
+	else
+		die "USE=modules-compress enabled but no MODULE_COMPRESS* configured"
 	fi
 
-	if [[ -v compress ]]; then
-		# could fail, assumes have commands that were needed for the kernel
-		einfo "Compressing modules (matching the kernel configuration) ..."
-		edob "${compress[@]}" -- "${@}"
-	fi
+	# could fail, assumes have commands that were needed for the kernel
+	einfo "Compressing modules (matching the kernel configuration) ..."
+	edob "${compress[@]}" -- "${@}"
 }
 
 # @FUNCTION: _modules_process_depmod.d
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 4/4] linux-mod.eclass: Fix xz compression options
  2023-12-28 10:35 [gentoo-dev] [PATCH 1/4] profiles/use.desc: Add global USE=modules-compress Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 2/4] kernel-{build,install}.eclass: Rename flag to modules-compress Michał Górny
  2023-12-28 10:35 ` [gentoo-dev] [PATCH 3/4] linux-mod-r1.eclass: Add USE=modules-compress Michał Górny
@ 2023-12-28 10:35 ` Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2023-12-28 10:35 UTC (permalink / raw)
  To: gentoo-dev; +Cc: Michał Górny

Match xz compression options to the ones used by the kernel,
as the xz decoder used by the kernel supports only a subset of the xz
format.

Bug: https://bugs.gentoo.org/920837
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/linux-mod.eclass | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/eclass/linux-mod.eclass b/eclass/linux-mod.eclass
index 26d8cac47ef0..c71ace53aa00 100644
--- a/eclass/linux-mod.eclass
+++ b/eclass/linux-mod.eclass
@@ -689,7 +689,9 @@ linux-mod_src_install() {
 		# and similarly compress the module being built if != NONE.
 
 		if linux_chkconfig_present MODULE_COMPRESS_XZ; then
-			xz -T$(makeopts_jobs) --memlimit-compress=50% -q ${modulename}.${KV_OBJ} || die "Compressing ${modulename}.${KV_OBJ} with xz failed"
+			# match kernel compression options for compatibility
+			# https://bugs.gentoo.org/920837
+			xz -T$(makeopts_jobs) --memlimit-compress=50% -q --check=crc32 --lzma2=dict=1MiB ${modulename}.${KV_OBJ} || die "Compressing ${modulename}.${KV_OBJ} with xz failed"
 			doins ${modulename}.${KV_OBJ}.xz
 			KV_OBJ_COMPRESS_EXT=".xz"
 		elif linux_chkconfig_present MODULE_COMPRESS_GZIP; then
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-28 10:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-28 10:35 [gentoo-dev] [PATCH 1/4] profiles/use.desc: Add global USE=modules-compress Michał Górny
2023-12-28 10:35 ` [gentoo-dev] [PATCH 2/4] kernel-{build,install}.eclass: Rename flag to modules-compress Michał Górny
2023-12-28 10:35 ` [gentoo-dev] [PATCH 3/4] linux-mod-r1.eclass: Add USE=modules-compress Michał Górny
2023-12-28 10:35 ` [gentoo-dev] [PATCH 4/4] linux-mod.eclass: Fix xz compression options Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox