2021-07-29 13:31:50

by Vasily Gorbik

[permalink] [raw]
Subject: [PATCH] s390/boot: fix zstd build for -march=z900

zstd decompression uses __builtin_clz() which fails back to __clzdi2()
when the kernel is built for older hardware like z900. This leads to
build failures like the following:
s390x-11.1.0-ld: /devel/src/kernel/arch/s390/boot/compressed/../../../../lib/zstd/bitstream.h:148: undefined reference to `__clzdi2'

Fix that by optionally including lib/clz_ctz.c into the decompressor.

Reported-by: kernel test robot <[email protected]>
Fixes: 7b034d9c1b08 ("s390/boot: add zstd support")
Signed-off-by: Vasily Gorbik <[email protected]>
---
arch/s390/boot/compressed/Makefile | 1 +
arch/s390/boot/compressed/clz_ctz.c | 2 ++
2 files changed, 3 insertions(+)
create mode 100644 arch/s390/boot/compressed/clz_ctz.c

diff --git a/arch/s390/boot/compressed/Makefile b/arch/s390/boot/compressed/Makefile
index 660c799d875d..e30d3fdbbc78 100644
--- a/arch/s390/boot/compressed/Makefile
+++ b/arch/s390/boot/compressed/Makefile
@@ -11,6 +11,7 @@ UBSAN_SANITIZE := n
KASAN_SANITIZE := n

obj-y := $(if $(CONFIG_KERNEL_UNCOMPRESSED),,decompressor.o) info.o
+obj-$(CONFIG_KERNEL_ZSTD) += clz_ctz.o
obj-all := $(obj-y) piggy.o syms.o
targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
targets += vmlinux.bin.xz vmlinux.bin.lzma vmlinux.bin.lzo vmlinux.bin.lz4
diff --git a/arch/s390/boot/compressed/clz_ctz.c b/arch/s390/boot/compressed/clz_ctz.c
new file mode 100644
index 000000000000..c3ebf248596b
--- /dev/null
+++ b/arch/s390/boot/compressed/clz_ctz.c
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "../../../../lib/clz_ctz.c"
--
2.25.4


2021-07-29 14:47:12

by Heiko Carstens

[permalink] [raw]
Subject: Re: [PATCH] s390/boot: fix zstd build for -march=z900

On Thu, Jul 29, 2021 at 03:29:19PM +0200, Vasily Gorbik wrote:
> zstd decompression uses __builtin_clz() which fails back to __clzdi2()
> when the kernel is built for older hardware like z900. This leads to
> build failures like the following:
> s390x-11.1.0-ld: /devel/src/kernel/arch/s390/boot/compressed/../../../../lib/zstd/bitstream.h:148: undefined reference to `__clzdi2'
>
> Fix that by optionally including lib/clz_ctz.c into the decompressor.
>
> Reported-by: kernel test robot <[email protected]>
> Fixes: 7b034d9c1b08 ("s390/boot: add zstd support")
> Signed-off-by: Vasily Gorbik <[email protected]>
> ---
> arch/s390/boot/compressed/Makefile | 1 +
> arch/s390/boot/compressed/clz_ctz.c | 2 ++
> 2 files changed, 3 insertions(+)
> create mode 100644 arch/s390/boot/compressed/clz_ctz.c

Applied, thanks!