The patch below was modified to work on top of Debian patches

[PATCH 3/6] Pass various runtime library flags to GCC.
* build-aux/ltmain.in (func_mode_link): Pass the
-shared-libgcc and -static-lib* flags along to GCC.

diff -urN libtool-2.4.7/build-aux/ltmain.in.orig libtool-2.4.7/build-aux/ltmain.in
--- libtool-2.4.7/build-aux/ltmain.in.orig	2022-05-25 13:57:50.311734300 +0200
+++ libtool-2.4.7/build-aux/ltmain.in	2022-05-25 14:01:54.621866600 +0200
@@ -7559,15 +7559,19 @@
       # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
       # -specs=*             GCC specs files
       # -stdlib=*            select c++ std lib with clang
+      # -{shared,static}-libgcc, -static-{libgfortran|libstdc++}
+      #                      link against specified runtime library
       # -fsanitize=*         Clang/GCC memory and address sanitizer
       # -fuse-ld=*           Linker select flags for GCC
-      # -static-*            direct GCC to link specific libraries statically
       # -fcilkplus           Cilk Plus language extension features for C/C++
       # -Wa,*                Pass flags directly to the assembler
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
-      -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus|-Wa,*)
+      -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*|-ftree-parallelize-loops=*| \
+      -fcilkplus|-fgnu-tm|-ffast-math|-funsafe-math-optimizations| \
+      -fvtable-verify*|-shared-libgcc|-static-libgcc|-static-libgfortran| \
+      -static-libstdc++)
         func_quote_arg pretty "$arg"
 	arg=$func_quote_arg_result
         func_append compile_command " $arg"
