[PATCH] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel

From: Jubin Zhong
Date: Fri Nov 19 2021 - 07:07:38 EST


xz_wrap.sh use $SRCARCH to detect the BCJ filter. However, assigning
arm BCJ filter to Thumb-2 kernel is not optimal. In my case, about 5%
decrease of image size is observed with armthumb BCJ filter:

Test results:
hardware: QEMU emulator version 3.1.0
config: vexpress_defconfig with THUMB2_KERNEL & KERNEL_XZ on
arm BCJ: 4029808
armthumb BCJ: 3827280

Choose armthumb BCJ filter for Thumb-2 kernel to make smaller images.

Signed-off-by: Jubin Zhong <zhongjubin@xxxxxxxxxx>
---
lib/decompress_unxz.c | 3 +++
scripts/xz_wrap.sh | 5 +++++
2 files changed, 8 insertions(+)

diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 9f4262e..7d6b952 100644
--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -131,6 +131,9 @@
#ifdef CONFIG_ARM
# define XZ_DEC_ARM
#endif
+#ifdef CONFIG_THUMB2_KERNEL
+# define XZ_DEC_ARMTHUMB
+#endif
#ifdef CONFIG_IA64
# define XZ_DEC_IA64
#endif
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
index 76e9cbc..47409bb 100755
--- a/scripts/xz_wrap.sh
+++ b/scripts/xz_wrap.sh
@@ -8,6 +8,7 @@
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
+. include/config/auto.conf

BCJ=
LZMA2OPTS=
@@ -20,4 +21,8 @@ case $SRCARCH in
sparc) BCJ=--sparc ;;
esac

+if [ -n "${CONFIG_THUMB2_KERNEL}" ];then
+ BCJ=--armthumb
+fi
+
exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB
--
1.8.5.6