bpo-30345: Add -g to LDFLAGS for LTO (GH-7709)

Add -g to LDFLAGS when compiling with LTO to get debug symbols.
diff --git a/configure b/configure
index 5187c6f..d427703 100755
--- a/configure
+++ b/configure
@@ -6427,6 +6427,14 @@
       esac
       ;;
   esac
+
+  if test "$ac_cv_prog_cc_g" = "yes"
+  then
+      # bpo-30345: Add -g to LDFLAGS when compiling with LTO
+      # to get debug symbols.
+      LTOFLAGS="$LTOFLAGS -g"
+  fi
+
   CFLAGS="$CFLAGS $LTOFLAGS"
   LDFLAGS="$LDFLAGS $LTOFLAGS"
 fi