bpo-38980: Only apply -fno-semantic-interposition if available (GH-22892)

diff --git a/configure b/configure
index df7118f..29f33b5 100755
--- a/configure
+++ b/configure
@@ -6484,8 +6484,44 @@
   DEF_MAKE_RULE="build_all"
   case $CC in
     *gcc*)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -fno-semantic-interposition" >&5
+$as_echo_n "checking whether C compiler accepts -fno-semantic-interposition... " >&6; }
+if ${ax_cv_check_cflags___fno_semantic_interposition+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  ax_check_save_flags=$CFLAGS
+  CFLAGS="$CFLAGS  -fno-semantic-interposition"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ax_cv_check_cflags___fno_semantic_interposition=yes
+else
+  ax_cv_check_cflags___fno_semantic_interposition=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  CFLAGS=$ax_check_save_flags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___fno_semantic_interposition" >&5
+$as_echo "$ax_cv_check_cflags___fno_semantic_interposition" >&6; }
+if test "x$ax_cv_check_cflags___fno_semantic_interposition" = xyes; then :
+
       CFLAGS_NODIST="$CFLAGS_NODIST -fno-semantic-interposition"
       LDFLAGS_NODIST="$LDFLAGS_NODIST -fno-semantic-interposition"
+
+else
+  :
+fi
+
       ;;
   esac