[FFmpeg-devel] [PATCH 2/2] When checking for compiler or linker flags, check if warnings are reported.

Diego 'Flameeyes' Pettenò flameeyes
Thu Oct 2 15:39:11 CEST 2008


Not all compilers and linkres fail with error when an option they
don't support is used during compilation or linking. For instance, the
Sun Studio and the Intel compiler suites, only issue warnings for
those cases.

Also, even GCC only issues warnings when a flag that cannot be used
with a given language (like -fvisibility-inlines-hidden used with the
C frontend).

With this patch, the checks for both compiler and linker flags will
ensure that no warning is issued that might show the compiler or
linker doesn't support the flag being tested. This will avoid adding
further warnings during build.

Further changes: when identifying the Intel C Compiler, further flags
were added to disable the warnings issued by the unsupported flags;
since this check disallows those from being added in the CFLAGS
variable in the first place, remove them, so that actually unsupported
flags used but not checked for will issue a warning.

Known possible issue: it expects the user to know its compiler and not
forcing through --extra-cflags or --extra-ldflags options that are not
supported, otherwise all the cflags/ldflags checks will fail. Doesn't
look too bad.
---

 configure |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 349464e..8ead633 100755
--- a/configure
+++ b/configure
@@ -226,7 +226,7 @@ Include the log file "$logfile" produced by configure as this will help
 solving the problem.
 EOF
     fi
-    rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH
+    rm -f $TMPC $TMPE $TMPH $TMPO $TMPS $TMPSH $TMPLOG $TMPRES
     exit 1
 }
 
@@ -423,7 +423,9 @@ add_extralibs(){
 
 check_cmd(){
     log "$@"
-    "$@" >> $logfile 2>&1
+    rm -f $TMPRES
+    ( "$@" 2>&1 && touch $TMPRES; ) | tee $TMPLOG >> $logfile
+    test -f $TMPRES
 }
 
 check_cc(){
@@ -471,16 +473,34 @@ check_ld(){
 
 check_cflags(){
     log check_cflags "$@"
-    check_cc "$@" <<EOF && add_cflags "$@"
+    check_cc "$@" <<EOF || return 1
 int x;
 EOF
+
+    grep -qi "warning" $TMPLOG && return 1
+    grep -qi "illegal option" $TMPLOG && return 1
+    grep -qi "unknown option" $TMPLOG && return 1
+    grep -qi "ignoring option" $TMPLOG && return 1
+    grep -qi "unrecognized" $TMPLOG && return 1
+
+    add_cflags "$@"
+    return 0
 }
 
 check_ldflags(){
     log check_ldflags "$@"
-    check_ld "$@" <<EOF && add_ldflags "$@"
+    check_ld "$@" <<EOF || return 1
 int main(void){ return 0; }
 EOF
+
+    grep -qi "warning" $TMPLOG && return 1
+    grep -qi "illegal option" $TMPLOG && return 1
+    grep -qi "unknown option" $TMPLOG && return 1
+    grep -qi "ignoring option" $TMPLOG && return 1
+    grep -qi "unrecognized" $TMPLOG && return 1
+
+    add_ldflags "$@"
+    return 0
 }
 
 check_header(){
@@ -1132,6 +1152,8 @@ TMPH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.h"
 TMPO="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.o"
 TMPS="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.S"
 TMPSH="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.sh"
+TMPLOG="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.log"
+TMPRES="${TMPDIR1}/ffmpeg-conf-${RANDOM}-$$-${RANDOM}.res"
 
 check_cflags -fasm
 check_cflags -std=c99
@@ -1891,12 +1913,7 @@ if $cc --version | grep -q Intel; then
   check_cflags -w1
   # -wd: Disable following warnings
   # 144, 167, 556: -Wno-pointer-sign
-  # 10006: ignoring unknown option -fno-signed-zeros
-  # 10156: ignoring option '-W'; no argument required
-  check_cflags -wd144,167,556,10006,10156
-  # 11030: Warning unknown option --as-needed
-  # 10156: ignoring option '-export'; no argument required
-  check_ldflags -wd10156,11030
+  check_cflags -wd144,167,556
   # Allow to compile with optimizations
   check_ldflags -march=$cpu
 fi





More information about the ffmpeg-devel mailing list