Re: [PATCH v6 3/3] riscv: fix building compressed EFI image

David Laight <[email protected]>
Newsgroups org.kernel.vger.linux-efi,org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel
Message-ID <20260427102922.08d0bcda@pumpkin>
On Sat, 25 Apr 2026 21:51:50 +0300
Dmitry Antipov <[email protected]> wrote:

> When building vmlinuz.efi with CONFIG_EFI_ZBOOT enabled,
> '__lshrdi3()' is also needed to fix yet another link error:
> 
> riscv32-linux-gnu-ld: drivers/firmware/efi/libstub/lib-cmdline.stub.o: in function `__efistub_.L49':
> __efistub_cmdline.c:(.init.text+0x202): undefined reference to `__efistub___lshrdi3'
> 
> And since riscv64 can have CONFIG_EFI_ZBOOT but doesn't need
> these library routines, rely on CONFIG_32BIT to manage linking
> of lib-ashldi3.o and lib-lshrdi3.o on riscv32 only.
> 
> Reported-by: Charlie Jenkins <[email protected]>
> Closes: https://lore.kernel.org/linux-riscv/[email protected]
> Tested-by: Charlie Jenkins <[email protected]>
> Suggested-by: Ard Biesheuvel <[email protected]>
> Signed-off-by: Dmitry Antipov <[email protected]>
> ---
> v6: adjust to match recent upstream changes
> v5: rely on CONFIG_32BIT rather than dedicated Kconfig symbol (Ard)
> v4: use more meaningful CONFIG_EFI_ZBOOT_USE_LIBGCC and adjust tags (Andy)
> v3: initial version to join the series
> ---
>  drivers/firmware/efi/libstub/Makefile | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
> index 983a438e35f3..e1c11d02a5cb 100644
> --- a/drivers/firmware/efi/libstub/Makefile
> +++ b/drivers/firmware/efi/libstub/Makefile
> @@ -95,7 +95,9 @@ CFLAGS_zboot-decompress-gzip.o	+= -I$(srctree)/lib/zlib_inflate
>  zboot-obj-$(CONFIG_KERNEL_ZSTD)	:= zboot-decompress-zstd.o lib-xxhash.o
>  CFLAGS_zboot-decompress-zstd.o	+= -I$(srctree)/lib/zstd
>  
> -zboot-obj-$(CONFIG_RISCV)	+= lib-clz_ctz.o lib-ashldi3.o
> +zboot-obj-$(CONFIG_RISCV)	+= lib-clz_ctz.o
> +zboot-riscv-obj-$(CONFIG_32BIT)	+= lib-ashldi3.o lib-lshrdi3.o
> +zboot-obj-$(CONFIG_RISCV)	+= lib-clz_ctz.o $(zboot-riscv-obj-y)

Doesn't that specify lib-clz_ctz.o twice ?
I think you could also use:
zboot-obj-$(CONFIG_RISCV)	+= lib-clz_ctz.o $(if $(CONFIG_32BIT),lib-ashldi3.o lib-lshrdi3.o)

	David

>  zboot-obj-$(CONFIG_LOONGARCH)	+= lib-clz_ctz.o lib-ashldi3.o
>  lib-$(CONFIG_EFI_ZBOOT)		+= zboot.o $(zboot-obj-y)
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.