diff --git a/configure b/configure
index 62a7f987d618443a387b1de8b5aed979026dc52f..04d51aee9225cd55aef539b7e57318924f4db916 100755
--- a/configure
+++ b/configure
@@ -601,12 +601,12 @@ check_yasm(){
 
 check_ld(){
     log check_ld "$@"
-    check_cc || return
     flags=''
     libs=''
     for f; do
         test "${f}" = "${f#-l}" && flags="$flags $f" || libs="$libs $f"
     done
+    check_cc $($filter_cflags $flags) || return
     check_cmd $ld $LDFLAGS $flags -o $TMPE $TMPO $extralibs $libs
 }