[PATCH] RISC-V/libgcc: Use `-fasynchronous-unwind-tables' for LIB2_DIVMOD_FUNCS

Maciej W. Rozycki macro@wdc.com
Sat Aug 29 13:18:34 GMT 2020

Use `-fasynchronous-unwind-tables' rather than `-fexceptions 
-fnon-call-exceptions' in LIB2_DIVMOD_FUNCS compilation flags so as to 
provide unwind tables for the affected functions while not pulling the 
unwinder proper, which is not required here.

Beyond saving program space it fixes a RISC-V glibc build error due to 
unsatisfied `malloc' and `free' references from the unwinder causing 
link errors with `ld.so' where libgcc has been built at -O0.

	* config/riscv/t-elf (LIB2_DIVMOD_EXCEPTION_FLAGS): New 

 As Mon, Aug 31st (a bank holiday in England) will be my last day at 
Western Digital and I won't be able to submit patches on behalf of the 
company afterwards here is a replacement change for RISC-V only in case 
the generic one discussed here:


does not go through.  While I won't be able to submit changes I will 
continue watching the discussion and I will be able to commit either 
change once there is the final outcome, just as anyone would.

 This change has passed full GCC regression testing with the 
`riscv64-linux-gnu' target, RV64/lp64d and RV32/ilp32d multilibs, using 
QEMU in the Linux user emulation mode.

 libgcc/config/riscv/t-elf |    2 ++
 1 file changed, 2 insertions(+)

Index: gcc/libgcc/config/riscv/t-elf
--- gcc.orig/libgcc/config/riscv/t-elf
+++ gcc/libgcc/config/riscv/t-elf
@@ -4,3 +4,5 @@ LIB2ADD += $(srcdir)/config/riscv/save-r
 	   $(srcdir)/config/riscv/div.S \
 	   $(srcdir)/config/riscv/atomic.c \
+# Avoid the full unwinder being pulled along with the division libcalls.
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fasynchronous-unwind-tables

More information about the Gcc-patches mailing list