Re: [PATCH 1/2] nios2: remove libgcc for lshrdi3, ashldi3, ashrdi3, muldi3, and ucmpdi2
From: Arnd Bergmann
Date: Mon Oct 19 2026 - 17:25:31 EST
On Mon, Oct 19, 2026, at 18:50, Dinh Nguyen wrote:
> Use the kernel's runtime support for lshrdi3, ashldi3, ashrdi3, muldi3,
> and ucmpdi2.
>
> Suggested-by: Arnd Bergmann <arnd@xxxxxxxx>
> Signed-off-by: Dinh Nguyen <dinguyen@xxxxxxxxxx>
You still link against libgcc in addition to the in-kernel
copies of these functions. While this may work correctly depending
on the link order, what I had suggested here is to remove libgcc
entirely here:
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile
index f1ff4ce0f1a2..173588c31abf 100644
--- a/arch/nios2/Makefile
+++ b/arch/nios2/Makefile
@@ -19,8 +19,6 @@ UTS_SYSNAME = Linux
export MMU
-LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) $(KCFLAGS) -print-libgcc-file-name)
-
KBUILD_AFLAGS += -march=r$(CONFIG_NIOS2_ARCH_REVISION)
KBUILD_CFLAGS += -pipe -D__linux__ -D__ELF__
@@ -37,7 +35,7 @@ KBUILD_CFLAGS += -DUTS_SYSNAME=\"$(UTS_SYSNAME)\"
KBUILD_CFLAGS += -fno-builtin
KBUILD_CFLAGS += -G 0
-libs-y += arch/nios2/lib/ $(LIBGCC)
+libs-y += arch/nios2/lib/
INSTALL_PATH ?= /tftpboot
nios2-boot := arch/$(ARCH)/boot
I expect you'll have to copy a few functions from the last gcc release
into arch/nios2/lib/ to make this work, at least (a GPLv2 compatible
version of) libgcc/config/nios2/lib2-divmod.c but maybe more.
Arnd