[FFmpeg-devel] [PATCHv3] avutil/attributes: extend av_uninit to clang

Ganesh Ajjanagadde gajjanag at mit.edu
Thu Oct 8 14:17:08 CEST 2015


On Thu, Oct 8, 2015 at 7:28 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> Hi,
>
> On Wed, Oct 7, 2015 at 8:50 PM, Ganesh Ajjanagadde <gajjanag at mit.edu> wrote:
>
>> On Wed, Oct 7, 2015 at 8:21 PM, Michael Niedermayer
>> <michael at niedermayer.cc> wrote:
>> > On Wed, Oct 07, 2015 at 06:22:08PM -0400, Ganesh Ajjanagadde wrote:
>> >> Commit 6dac8c8327 disabled av_uninit for clang, due to some useless
>> warnings.
>> >> The concept of av_uninit is inherently useful though. This patch
>> silences a
>> >> bunch of warnings on clang e.g
>> >>
>> http://fate.ffmpeg.org/log.cgi?time=20150918181527&log=compile&slot=x86_64-darwin-clang-polly-vectorize-stripmine-3.7
>> .
>> >> Furthermore, it should be useful for general usage of av_uninit in
>> future.
>> >>
>> >> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> >> ---
>> >>  libavutil/attributes.h | 8 ++++++++
>> >>  1 file changed, 8 insertions(+)
>> >>
>> >> diff --git a/libavutil/attributes.h b/libavutil/attributes.h
>> >> index 5c6b9de..ceb9e29 100644
>> >> --- a/libavutil/attributes.h
>> >> +++ b/libavutil/attributes.h
>> >> @@ -147,6 +147,14 @@
>> >>
>> >>  #if defined(__GNUC__) && !defined(__INTEL_COMPILER) &&
>> !defined(__clang__)
>> >>  #    define av_uninit(x) x=x
>> >> +#elif defined(__clang__)
>> >> +#if __has_warning("-Wuninitialized")
>> >> +#    define av_uninit(x) \
>> >> +        _Pragma("clang diagnostic push") \
>> >> +        _Pragma("clang diagnostic ignored \"-Wuninitialized\"") \
>> >> +        x=x \
>> >> +        _Pragma("clang diagnostic pop")
>> >> +#endif
>> >
>> > this breaks
>> > make distclean ; ./configure --cc='ccache clang' && make -j12
>> > it does not break clang alone and clearing the ccache cache does not
>> > help
>> > ccache version 3.1.6
>> >
>> > In file included from libavfilter/af_aecho.c:1:
>> > libavfilter/af_aecho.c:226:315: error: expected identifier or '('
>> > static void echo_samples_dblp(AudioEchoContext *ctx, uint8_t
>> **delayptrs, uint8_t * const *src, uint8_t **dst, int nb_samples, int
>> channels) { const double out_gain = ctx->out_gain; const double in_gain =
>> ctx->in_gain; const int nb_echoes = ctx->nb_echoes; const int max_samples =
>> ctx->max_samples; int i, j, chan,#pragma clang diagnostic push#pragma clang
>> diagnostic ignored "-Wuninitialized" index=index#pragma clang diagnostic
>> pop; ((void)0); for (chan = 0; chan < channels; chan++) { const double *s =
>> (double *)src[chan]; double *d = (double *)dst[chan]; double *dbuf =
>> (double *)delayptrs[chan]; index = ctx->delay_index; for (i = 0; i <
>> nb_samples; i++, s++, d++) { double out, in; in = *s; out = in * in_gain;
>> for (j = 0; j < nb_echoes; j++) { int ix = index + max_samples -
>> ctx->samples[j]; ix = (((ix) >= (max_samples)) ? (ix) - (max_samples) :
>> (ix)); out += dbuf[ix] * ctx->decay[j]; } out *= out_gain; *d =
>> av_clipd_c(out, -1.0, 1.0); dbuf[index] = in; index = (((index + 1) >=
>> (max_samples)) ? (index + 1) - (max_samples) : (index + 1)); } }
>> ctx->delay_index = index; }
>> >
>>
>>
>>
>>              ^
>> >
>> > [...]
>>
>> ccache and clang have some weird interaction issues -for instance a
>> lot of -Warray-bounds are triggered for glibc functions like strcmp. I
>> vaguely recall some suggestion to use an environment variable to avoid
>> the breakage:
>> http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
>>
>> Anyway, this sounds like it needs to be fixed upstream with clang or
>> ccache or possibly both.
>
>
> I agree, and am a little sad that the patch can't go in yet. Would you mind
> filing a bug with ccache? According to that blog post, they (ccache devs)
> do look at their bug tracker, and we have all information necessary to make
> a relatively trivial test case for them (just the av_uninit define and a
> one-line main() function that uses av_uninit should do the trick).

Will do by the end of the week.

>
> Ronald
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list