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

Måns Rullgård mans
Thu Oct 2 13:03:51 CEST 2008


Diego 'Flameeyes' Petten? wrote:
> Some compilers, namely the Sun Studio compiler, don't abort the build
> when a flag is not supported, but just throw a warning. With these
> changes, the output of the compiler is logged down, and can be grepped
> for particular common warnings.
>
> Also, the output is forced to use C-locale, as translated output
> messages wouldn't be able to be read through grepping.
>
> With this change there is no change in GCC's behaviour, but the Sun
> Studio compiler won't be asked to use any flag it does not support
> properly.
> ---
>
>  configure |   26 ++++++++++++++++++--------
>  1 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/configure b/configure
> index 0fb0721..61055fd 100755
> --- a/configure
> +++ b/configure
> @@ -222,7 +222,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
>  }
>
> @@ -419,21 +419,23 @@ add_extralibs(){
>
>  check_cmd(){
>      log "$@"
> -    "$@" >> $logfile 2>&1
> +    rm -f $TMPRES
> +    ( "$@" 2>&1 && touch $TMPRES; ) | tee $TMPLOG >> $logfile
> +    test -f $TMPRES

I don't like the look of this.  I'm sure there's a better way, but I
have to think about it.

>  }
>
>  check_cc(){
>      log check_cc "$@"
>      cat > $TMPC
>      log_file $TMPC
> -    check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
> +    LC_ALL=C check_cmd $cc $CFLAGS "$@" -c -o $TMPO $TMPC
>  }

Just set LC_ALL=C at the start of configure instead.  I've been meaning
to do that anyway.

>  check_cflags(){
>      log check_cflags "$@"
> -    check_cc "$@" <<EOF && add_cflags "$@"
> +    check_cc "$@" <<EOF || return
>  int x;
>  EOF
> +
> +    grep -qi "warning" $TMPLOG && return
> +    grep -qi "illegal option" $TMPLOG && return
> +    grep -qi "unrecognized" $TMPLOG && return
> +
> +    add_cflags "$@"
>  }

This has two problems.  Firstly, the return value from the function is
wrong.  Secondly, warnings are expected, or at least accepted, in a few
of the tests (I don't recall which ones), so this is overly strict.

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-devel mailing list