Skip to contentSkip to conversation

Remove libgcc dependency for ARC

PATCH In review Vineet Gupta 2 participants 6 messages Nov 19 Synopsys ARC architecture

lore
Share & tools
lore

Vineet Gupta

author maintainer
#0 lore raw

cover Remove libgcc dependency for ARC

Hi,

Arnd pestered me to do this.

Most of the generic emulation routines were present in lib/ flready. Thanks to Dinh Nguyen and Simon Schuster for filling in the rest.

Thx,
-Vineet

Vineet Gupta (4):
ARC: math emul: elide 64/64 divide and floating point routines
ARC: math emul: use existing lib versions of libgcc routines Revert "ARC: Strip libgcc debug information when generating BTF"
ARC: stop linking libgcc

 arch/arc/Kconfig           | 10 ++++++++++
 arch/arc/Makefile          |  9 ---------
 arch/arc/kernel/arcksyms.c | 37 -------------------------------------
 arch/arc/lib/Makefile      |  8 --------
 4 files changed, 10 insertions(+), 54 deletions(-)
Signature · 1 line
2.53.0
author maintainer
#1 lore raw

PATCH 1/4 ARC: math emul: elide 64/64 divide and floating point routines

64/63 divide are not needed in 32-bit kernels.
FP shouldn't be needed at all.

---
 arch/arc/kernel/arcksyms.c | 14 --------------
 1 file changed, 14 deletions(-)
arch/arc/kernel/arcksyms.c +0 -14
index 8851c0a19e09..c22055e66cfe 100644
@@ -11,7 +11,6 @@
 extern void __ashldi3(void);
 extern void __ashrdi3(void);
 extern void __divsi3(void);
-extern void __divsf3(void);
 extern void __lshrdi3(void);
 extern void __modsi3(void);
 extern void __muldi3(void);
@@ -19,17 +18,10 @@ extern void __ucmpdi2(void);
 extern void __udivsi3(void);
 extern void __umodsi3(void);
 extern void __cmpdi2(void);
-extern void __fixunsdfsi(void);
-extern void __muldf3(void);
-extern void __divdf3(void);
-extern void __floatunsidf(void);
-extern void __floatunsisf(void);
-extern void __udivdi3(void);
 
 EXPORT_SYMBOL(__ashldi3);
 EXPORT_SYMBOL(__ashrdi3);
 EXPORT_SYMBOL(__divsi3);
-EXPORT_SYMBOL(__divsf3);
 EXPORT_SYMBOL(__lshrdi3);
 EXPORT_SYMBOL(__modsi3);
 EXPORT_SYMBOL(__muldi3);
@@ -37,12 +29,6 @@ EXPORT_SYMBOL(__ucmpdi2);
 EXPORT_SYMBOL(__udivsi3);
 EXPORT_SYMBOL(__umodsi3);
 EXPORT_SYMBOL(__cmpdi2);
-EXPORT_SYMBOL(__fixunsdfsi);
-EXPORT_SYMBOL(__muldf3);
-EXPORT_SYMBOL(__divdf3);
-EXPORT_SYMBOL(__floatunsidf);
-EXPORT_SYMBOL(__floatunsisf);
-EXPORT_SYMBOL(__udivdi3);
 
 /* ARC optimised assembler routines */
 EXPORT_SYMBOL(memset);
Signature · 1 line
2.53.0
author maintainer
#2 lore raw

PATCH 2/4 ARC: math emul: use existing lib versions of libgcc routines

In reply to Vineet Gupta

Use the existing lib/ emulation.

Divide/modulo need some mention: technically emulation is only needed for hardware lacking the insns (ARCompact ISA or ARCv2 ISA based cores configured w/o divider and/or those insns disabled in the build (-mno-div-rem). But to be future-proof (thinking modules) just add them unconditionally.

---
 arch/arc/Kconfig           | 10 ++++++++++
 arch/arc/kernel/arcksyms.c | 23 -----------------------
 2 files changed, 10 insertions(+), 23 deletions(-)
arch/arc/Kconfig +10 -0
index 80e61175bf52..9bf747882f2a 100644
@@ -25,6 +25,16 @@ config ARC
 	select GENERIC_ATOMIC64 if !ISA_ARCV2 || !(ARC_HAS_LL64 && ARC_HAS_LLSC)
 	# for now, we don't need GENERIC_IRQ_PROBE, CONFIG_GENERIC_IRQ_CHIP
 	select GENERIC_IRQ_SHOW
+	select GENERIC_LIB_ASHLDI3
+	select GENERIC_LIB_ASHRDI3
+	select GENERIC_LIB_LSHRDI3
+	select GENERIC_LIB_MULDI3
+	select GENERIC_LIB_CMPDI2
+	select GENERIC_LIB_UCMPDI2
+	select GENERIC_LIB_MODSI3
+	select GENERIC_LIB_UMODSI3
+	select GENERIC_LIB_DIVSI3
+	select GENERIC_LIB_UDIVSI3
 	select GENERIC_PCI_IOMAP
 	select GENERIC_SCHED_CLOCK
 	select GENERIC_SMP_IDLE_THREAD
arch/arc/kernel/arcksyms.c +0 -23
index c22055e66cfe..bba133fdd1b6 100644
@@ -7,29 +7,6 @@
 
 #include <linux/module.h>
 
-/* libgcc functions, not part of kernel sources */
-extern void __ashldi3(void);
-extern void __ashrdi3(void);
-extern void __divsi3(void);
-extern void __lshrdi3(void);
-extern void __modsi3(void);
-extern void __muldi3(void);
-extern void __ucmpdi2(void);
-extern void __udivsi3(void);
-extern void __umodsi3(void);
-extern void __cmpdi2(void);
-
-EXPORT_SYMBOL(__ashldi3);
-EXPORT_SYMBOL(__ashrdi3);
-EXPORT_SYMBOL(__divsi3);
-EXPORT_SYMBOL(__lshrdi3);
-EXPORT_SYMBOL(__modsi3);
-EXPORT_SYMBOL(__muldi3);
-EXPORT_SYMBOL(__ucmpdi2);
-EXPORT_SYMBOL(__udivsi3);
-EXPORT_SYMBOL(__umodsi3);
-EXPORT_SYMBOL(__cmpdi2);
-
 /* ARC optimised assembler routines */
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memcpy);
Signature · 1 line
2.53.0
author maintainer
#3 lore raw

PATCH 3/4 Revert "ARC: Strip libgcc debug information when generating BTF"

In reply to Vineet Gupta

This reverts commit ca201ad6e92a1924138e83ff966f7a091e3bbe6e.

This is in preparation of libgcc dependency removal. And its better then deleteing those bits anyways.

---
 arch/arc/Makefile     | 9 +--------
 arch/arc/lib/Makefile | 8 --------
 2 files changed, 1 insertion(+), 16 deletions(-)
arch/arc/Makefile +1 -8
index 4ea705a331c7..868805ffcfea 100644
@@ -86,14 +86,7 @@ core-$(CONFIG_ARC_PLAT_TB10X)	+= arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X)	+= arch/arc/plat-axs10x/
 core-$(CONFIG_ARC_SOC_HSDK)	+= arch/arc/plat-hsdk/
 
-libs-y		+= arch/arc/lib/
-
-ifdef CONFIG_DEBUG_INFO_BTF
-export LIBGCC := $(LIBGCC)
-libs-y		+= arch/arc/lib/libgcc.a
-else
-libs-y		+= $(LIBGCC)
-endif
+libs-y		+= arch/arc/lib/ $(LIBGCC)
 
 boot		:= arch/arc/boot
 
arch/arc/lib/Makefile +0 -8
index 2807ee24f27e..30158ae69fd4 100644
@@ -13,11 +13,3 @@ lib-$(CONFIG_ISA_ARCV2)		+=memcpy-archs-unaligned.o
 else
 lib-$(CONFIG_ISA_ARCV2)		+=memcpy-archs.o
 endif
-
-# libgcc can contain complex floating-point debug types unsupported by BTF.
-# Strip only the debug information from a local copy of the selected archive.
-always-$(CONFIG_DEBUG_INFO_BTF) += libgcc.a
-OBJCOPYFLAGS_libgcc.a := --strip-debug
-
-$(obj)/libgcc.a: $(LIBGCC) FORCE
-	$(call if_changed,objcopy)
Signature · 1 line
2.53.0
author maintainer
#4 lore raw

PATCH 4/4 ARC: stop linking libgcc

In reply to Vineet Gupta

With the generic lib/ versions of the shift/multiply/compare helpers, the 32-bit divide routines (only needed without hardware div/rem) and clz/ctz all provided by the kernel, and the 64/64 divide and floating point routines gone, nothing in the kernel or modules resolves against libgcc any more.

Drop it from the link so that any new dependency on it (e.g. a raw 64-bit division instead of div_u64()) shows up as a build failure rather than silently pulling in libgcc code.

---
 arch/arc/Makefile | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arc/Makefile +1 -3
index 868805ffcfea..9f34198d74a3 100644
@@ -71,8 +71,6 @@ cflags-$(disable_small_data)		+= -mno-sdata
 cflags-$(CONFIG_CPU_BIG_ENDIAN)		+= -mbig-endian
 ldflags-$(CONFIG_CPU_BIG_ENDIAN)	+= -EB
 
-LIBGCC	= $(shell $(CC) $(cflags-y) --print-libgcc-file-name)
-
 # Modules with short calls might break for calls into builtin-kernel
 KBUILD_CFLAGS_MODULE	+= -mlong-calls -mno-millicode
 
@@ -86,7 +84,7 @@ core-$(CONFIG_ARC_PLAT_TB10X)	+= arch/arc/plat-tb10x/
 core-$(CONFIG_ARC_PLAT_AXS10X)	+= arch/arc/plat-axs10x/
 core-$(CONFIG_ARC_SOC_HSDK)	+= arch/arc/plat-hsdk/
 
-libs-y		+= arch/arc/lib/ $(LIBGCC)
+libs-y		+= arch/arc/lib/
 
 boot		:= arch/arc/boot
 
Signature · 1 line
2.53.0
#5 lore raw
In reply to Vineet Gupta
Quoted 4 lines · Vineet Gupta

Hi,

Arnd pestered me to do this.

Quoted 8 lines

Most of the generic emulation routines were present in lib/ flready. Thanks to Dinh Nguyen and Simon Schuster for filling in the rest.

Vineet Gupta (4):
ARC: math emul: elide 64/64 divide and floating point routines
ARC: math emul: use existing lib versions of libgcc routines Revert "ARC: Strip libgcc debug information when generating BTF"
ARC: stop linking libgcc

Thanks, I've merged this and the openrisc patch I sent into the asm-generic tree now, on top of the merge of the nios2 branch.

Arnd