[FFmpeg-devel] [PATCH v6 1/3] mips: improve detection of ISAs, FPU and ASEs (DSP, MSA)

Michael Niedermayer michael at niedermayer.cc
Mon Jan 25 13:23:25 CET 2016


On Mon, Jan 25, 2016 at 11:50:36AM +0000, Vicente Olivert Riera wrote:
> On 25/01/16 11:32, Michael Niedermayer wrote:
> > On Mon, Jan 25, 2016 at 10:35:12AM +0000, Vicente Olivert Riera wrote:
> >> On 21/01/16 23:17, Michael Niedermayer wrote:
> >>> On Wed, Jan 20, 2016 at 02:33:21PM +0000, Vicente Olivert Riera wrote:
> >>>> On 20/01/16 13:15, Michael Niedermayer wrote:
> >>>>> On Wed, Jan 20, 2016 at 12:21:37PM +0000, Vicente Olivert Riera wrote:
> >>>>>> On 20/01/16 12:05, Michael Niedermayer wrote:
> >>>>>>> On Wed, Jan 20, 2016 at 11:37:52AM +0000, Vicente Olivert Riera wrote:
> >>>>>>>> Hello Michael,
> >>>>>>>>
> >>>>>>>> On 19/01/16 22:11, Michael Niedermayer wrote:
> >>>>>>>>> On Thu, Jan 14, 2016 at 02:59:03PM +0000, Vicente Olivert Riera wrote:
> >>>>>>>>>> Signed-off-by: Vicente Olivert Riera <Vincent.Riera at imgtec.com>
> >>>>>>>>>> ---
> >>>>>>>>>> Changes v5 -> v6:
> >>>>>>>>>>  - Multiple changes:
> >>>>>>>>>>    - Use separate if blocks when detecting the MIPS ISA, this way when a block
> >>>>>>>>>>      disables one ISA it will be detected by the next one. Before the elif was
> >>>>>>>>>>      preventing this to be done.
> >>>>>>>>>>    - Don't use check_cflags and use only check_ldflags instead, which will
> >>>>>>>>>>      check if that flag is valid for compiling and linking. The compiler may
> >>>>>>>>>>      accept some cflags for compiling but not for linking, so if we check first
> >>>>>>>>>>      for the cflags it will succeed, and the cflags will be added to the CFLAGS
> >>>>>>>>>>      variable despite of the check_ldflags failing after that. This can cause
> >>>>>>>>>>      problems because of having multiple incompatible cflags enabled at the same
> >>>>>>>>>>      time.
> >>>>>>>>>>    - Check if mipsfpu has been disabled, and if so, then use -msoft-float. This
> >>>>>>>>>>      way we override the compiler default behavious which can be building for
> >>>>>>>>>>      hard-float.
> >>>>>>>>>>    - Explicitly disable the features that fail any check by adding "|| disable
> >>>>>>>>>>      $feature" at the end of the checks chain.
> >>>>>>>>>>
> >>>>>>>>>> Changes v4 -> v5:
> >>>>>>>>>>  - Check for msa.h and disable msa if not found.
> >>>>>>>>>>
> >>>>>>>>>> Changes v3 -> v4:
> >>>>>>>>>>  - Nothing.
> >>>>>>>>>>
> >>>>>>>>>> Changes v2 -> v3:
> >>>>>>>>>>  - Nothing.
> >>>>>>>>>>
> >>>>>>>>>> Changes v1 -> v2:
> >>>>>>>>>>  - Add a block of code for mipsdspr2 which was previously placed in the
> >>>>>>>>>>    first patch of this series causing a syntax error in the configure
> >>>>>>>>>>    script.
> >>>>>>>>>>    https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2015-November/183444.html
> >>>>>>>>>
> >>>>>>>>> make distclean ; ../configure --cross-prefix=/usr/mips-linux-gnu/bin/ --cc='ccache mips-linux-gnu-gcc-4.4' --arch=mips --target-os=linux --enable-cross-compile  --disable-mipsfpu && make -j12
> >>>>>>>>> results in pages of:
> >>>>>>>>>
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libswresample/libswresample.a(dither.o) uses soft float
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libswresample/libswresample.a(resample.o) uses soft float
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libswresample/libswresample.a(resample_dsp.o) uses soft float
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libavutil/libavutil.a(adler32.o) uses soft float
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libavutil/libavutil.a(aes.o) uses soft float
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libavutil/libavutil.a(aes_ctr.o) uses soft float
> >>>>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: libavfilter/filtfmts-test uses hard float, libavutil/libavutil.a(audio_fifo.o) uses soft float
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> [...]
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> I can't reproduce your issue. Look:
> >>>>>>>>
> >>>>>>>> $ make distclean ; ./configure --cross-prefix=mips-linux-gnu-
> >>>>>>>> --arch=mips --target-os=linux --enable-cross-compile --disable-mipsfpu
> >>>>>>>>
> >>>>>>>> And then:
> >>>>>>>>
> >>>>>>>> $ make -j1 V=1 2>&1 | tee build.log
> >>>>>>>>
> >>>>>>>> And then:
> >>>>>>>>
> >>>>>>>> $ grep "uses soft float" build.log
> >>>>>>>> $ grep "filtfmts-test" build.log
> >>>>>>>>
> >>>>>>>> It gives me nothing.
> >>>>>>>>
> >>>>>>>> Also I try to find for that filtfmts-test file which your logs say that
> >>>>>>>> is using hard-float, and I cannot find it:
> >>>>>>>>
> >>>>>>>
> >>>>>>>> $ find . -name "filtfmts-test*"
> >>>>>>>> $
> >>>>>>>
> >>>>>>> see libavfilter/filtfmts.c
> >>>>>>
> >>>>>> But do you have a generated filtfmts-test binary or a filtfmts.o file?
> >>>>>> Because when my build is finished I don't any anything of that.
> >>>>>
> >>>>> make libavfilter/filtfmts-test
> >>>>> CC      libavfilter/filtfmts-test.o
> >>>>> libavfilter/filtfmts.c:141:9: warning: ignoring return value of function declared with warn_unused_result attribute [-Wunused-result]
> >>>>>         ff_default_query_formats(filter_ctx);
> >>>>>         ^~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~
> >>>>> 1 warning generated.
> >>>>> LD      libavfilter/filtfmts-test
> >>>>>
> >>>>> the source and object files differ in their names
> >>>>>
> >>>>
> >>>> I see. Ok, look at this:
> >>>>
> >>>> $ make libavfilter/filtfmts-test
> >>>> CC	libavfilter/filtfmts-test.o
> >>>> libavfilter/filtfmts.c: In function 'main':
> >>>> libavfilter/filtfmts.c:141:9: warning: ignoring return value of
> >>>> 'ff_default_query_formats', declared with attribute warn_unused_result
> >>>> [-Wunused-result]
> >>>>          ff_default_query_formats(filter_ctx);
> >>>>          ^
> >>>> LD	libavfilter/filtfmts-test
> >>>>
> >>>> $ mips-linux-gnu-objdump -x libavfilter/filtfmts-test | grep "FP ABI"
> >>>> FP ABI: Soft float
> >>>>
> >>>> It shows to me that it has been for soft-float.
> >>>>
> >>>>>>
> >>>>>>> our compilers differ
> >>>>>>> the one i have here is a binary from emdebian
> >>>>>>> are you droping support for that ?
> >>>>>>> if so that should be clearly stated in the commit message, and  the
> >>>>>>> compiler cleanly detected and a clear warning given to the user why
> >>>>>>> his/her compiler isnt supported and what is supported
> >>>>>>
> >>>>>> Well, my intention isn't dropping support for anything, although this is
> >>>>>> what the emdebian website says:
> >>>>>>
> >>>>>> "Status of Emdebian distributions
> >>>>>>
> >>>>>> As of July 2014, updates to the Emdebian distributions ceased. There
> >>>>>> will be no further updates and no further stable releases."
> >>>>>
> >>>>> i know, the problem is not me, i can update, IIRC you guys posted a
> >>>>> binary already
> >>>>> but others might use similarly build or old compilers
> >>>>> so keeping this one here gives some wider coverage ... and its less
> >>>>> work
> >>>>
> >>>> I also want to keep it.
> >>>>
> >>>>>>
> >>>>>> Anyway, how can I obtain the same compiler as you have in order to try
> >>>>>> reproducing the bug?
> >>>>>
> >>>>> i dont know, if they arent on emdian anymore
> >>>>> i dont seem to have the deb files in var/cache/apt/archive anymore
> >>>>>
> >>>>> Package: gcc-4.4-mips-linux-gnu
> >>>>> Status: install ok installed
> >>>>> Priority: extra
> >>>>> Section: devel
> >>>>> Installed-Size: 3088
> >>>>> Maintainer: Debian GCC Maintainers <debian-gcc at lists.debian.org>
> >>>>> Architecture: amd64
> >>>>> Source: gcc-4.4
> >>>>> Version: 4.4.5-8
> >>>>> Provides: c-compiler-mips-linux-gnu
> >>>>> Depends: gcc-4.4-mips-linux-gnu-base (= 4.4.5-8), cpp-4.4-mips-linux-gnu (= 4.4.5-8), binutils-mips-linux-gnu (>= 2.20.1-15~), libgcc1-mips-cross (>= 1:4.4.5-8), libgomp1-mips-cross (>= 4.4.5-8), libc6 (>= 2.11)
> >>>>> Recommends: libc6-dev-mips-cross (>= 2.5)
> >>>>> Suggests: gcc-4.4-multilib-mips-linux-gnu, libmudflap0-4.4-dev-mips-cross (>= 4.4.5-8), gcc-4.4-doc (>= 4.4.4-17), gcc-4.4-locales (>= 4.4.4-17), libgcc1-dbg-mips-cross, libgomp1-dbg-mips-cross, libmudflap0-dbg-mips-cross, libcloog-ppl0 (>= 0.15.9-2~), libppl-c2, libppl7
> >>>>> Description: The GNU C compiler
> >>>>>  This is the GNU C compiler, a fairly portable optimizing compiler for C.
> >>>>>  .
> >>>>>  This package contains C cross-compiler for mips architecture.
> >>>>> Homepage: http://gcc.gnu.org/
> >>>>>
> >>>>
> >>>> Ok then.
> >>>>
> >>>>>>
> >>>>>>> make distclean ; ../configure --cross-prefix=/usr/mips-linux-gnu/bin/ --cc='mips-linux-gnu-gcc-4.4' --arch=mips --target-os=linux --enable-cross-compile  --disable-mipsfpu && make -j12  >& build
> >>>>>>>
> >>>>>>> grep 'uses soft float' build | wc
> >>>>>>> 2327   24879  389225
> >>>>>>>
> >>>>>>> echo 'int main(void){ return 0; }' | mips-linux-gnu-gcc-4.4  -x c - -o out.o
> >>>>>>> echo 'int main(void){ return 0; }' | mips-linux-gnu-gcc-4.4  -x c - -o out.o -msoft-float
> >>>>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: out.o uses hard float, /tmp/ccFlutMG.o uses soft float
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>> But I don't understand how your compiler built something for hard-float
> >>>>>> when the -msoft-float option should be used instead. This is what I have
> >>>>>> (note that I passed V=1 to the make command):
> >>>>>>
> >>>>>> $ grep '\-mhard-float' build.log | wc -l
> >>>>>> 0
> >>>>>> $ grep '\-msoft-float' build.log | wc -l
> >>>>>> 1411
> >>>>>> $ grep "mips-linux-gnu-gcc" build.log | wc -l
> >>>>>> 1411
> >>>>>>
> >>>>>> So the -mhard-float option wasn't used at all, and the -msoft-float one
> >>>>>> was used every time the compiler was called.
> >>>>>>
> >>>>>> I'm curious, can you show me your output for those same commands, please?
> >>>>>
> >>>>> before the patch:
> >>>>> grep '\-mhard-float' build.log-V1-disable-mipsfpu | wc -l
> >>>>> 0
> >>>>>
> >>>>> grep '\-msoft-float' build.log-V1-disable-mipsfpu | wc -l
> >>>>> 0
> >>>>
> >>>> So, before the patch when you pass the --disable-mipsfpu option, what
> >>>> configure does is not adding the -mhard-float option to the CFLAGS. But
> >>>> also it doesn't add -msoft-float. So no float option is passed to the
> >>>> compiler at all.
> >>>>
> >>>> Given that you don't pass any of those two options to the compiler, the
> >>>> default one will be used, which I think it will be -mhard-float.
> >>>>
> >>>> Look at this simple test:
> >>>>
> >>>> $ cat test.c
> >>>> int main(){return 0;}
> >>>> $ # USING -mhard-float
> >>>> $ mips-linux-gnu-gcc -mhard-float test.c
> >>>> $ mips-linux-gnu-objdump -x a.out | grep "FP ABI"
> >>>> FP ABI: Hard float (double precision)
> >>>> $ # USING -msoft-float
> >>>> $ mips-linux-gnu-gcc -msoft-float test.c
> >>>> $ mips-linux-gnu-objdump -x a.out | grep "FP ABI"
> >>>> FP ABI: Soft float
> >>>> $ # USING COMPILER'S DEFAULT
> >>>> $ mips-linux-gnu-gcc test.c
> >>>> $ mips-linux-gnu-objdump -x a.out | grep "FP ABI"
> >>>> FP ABI: Hard float (double precision)
> >>>>
> >>>> So, as you can see, before that patch, when we were passing
> >>>> --disable-mipsfpu to the configure script, we weren't building ffmpeg
> >>>> for soft-float. We were actually building it for the compiler's default
> >>>> floatness, which could be either soft-float or (more likely) hard-float.
> >>>>
> >>>> That's why you didn't see those warnings, because everything was being
> >>>> built for hard-float.
> >>>>
> >>>>> after the patch:
> >>>>> grep '\-mhard-float' build.log-V1-disable-mipsfpu-with-patch | wc -l
> >>>>> 0
> >>>>> grep '\-msoft-float' build.log-V1-disable-mipsfpu-with-patch | wc -l
> >>>>> 1428
> >>>>> grep "mips-linux-gnu-gcc" build.log-V1-disable-mipsfpu-with-patch | wc -l
> >>>>> 1428
> >>>>
> >>>> This is what doesn't make sense to me. Every time your compiler is
> >>>> called it has the -msoft-float option with it, so everything it has
> >>>> built was built for soft-float.
> >>>>
> >>>>> also forget about filtfmts, its not specifici to that
> >>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: ffprobe_g uses hard float, libavutil/libavutil.a(samplefmt.o) uses soft float
> >>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: ffprobe_g uses hard float, libavutil/libavutil.a(sha.o) uses soft float
> >>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: ffprobe_g uses hard float, libavutil/libavutil.a(sha512.o) uses soft float
> >>>>> /usr/lib/gcc/mips-linux-gnu/4.4.5/../../../../mips-linux-gnu/bin/ld: Warning: ffprobe_g uses hard float, libavutil/libavutil.a(stereo3d.o) uses soft float
> >>>>
> >>>> Can you grep the output of "mips-linux-gnu-objdump -x ffprobe_g" and
> >>>> search for "FP ABI" in order to see if it actually uses hard float?
> >>>
> >>> before and after the patch there is no match, greping for ABI
> >>> 1 .note.ABI-tag 00000020  004001a4  004001a4  000001a4  2**2
> >>> 004001a4 l    d  .note.ABI-tag  00000000              .note.ABI-tag
> >>>
> >>> mips-linux-gnu-objdump -x ffprobe_g | grep 'ABI'
> >>>   1 .note.ABI-tag 00000020  004001a4  004001a4  000001a4  2**2
> >>> 004001a4 l    d  .note.ABI-tag  00000000              .note.ABI-tag
> >>>
> >>> also both mips-linux-gnu-objdump and the normal hosts objdump give the
> >>> same result
> >>>
> >>> [...]
> >>>
> >>
> >> Hello Michael,
> >>
> >> I don't know what else to do. The think is that those are warning
> >> messages, so it seems your build doesn't fail.
> > 
> > yes but the binary doesnt work
> > 
> > make fate
> > TEST    checkasm
> > TEST    source
> > TEST    api-flac
> > TEST    lavf-aiff
> > --- ffmpeg/tests/ref/lavf/aiff 2016-01-25 00:20:45.154515021 +0100
> > +++ tests/data/fate/lavf-aiff   2016-01-25 12:14:24.507417107 +0100
> > @@ -1,3 +0,0 @@
> > -2c129d88acef834e32869145fe792b9c *./tests/data/lavf/lavf.aif
> > -88270 ./tests/data/lavf/lavf.aif
> > -./tests/data/lavf/lavf.aif CRC=0x3a1da17e
> > Test lavf-aiff failed. Look at tests/data/fate/lavf-aiff.err for details.
> > make: *** [fate-lavf-aiff] Error 1
> > 
> >   libavutil      55. 14.100 / 55. 14.100
> >   libavcodec     57. 22.100 / 57. 22.100
> >   libavformat    57. 23.100 / 57. 23.100
> >   libavdevice    57.  0.100 / 57.  0.100
> >   libavfilter     6. 27.100 /  6. 27.100
> >   libswscale      4.  0.100 /  4.  0.100
> >   libswresample   2.  0.101 /  2.  0.101
> >   libpostproc    54.  0.100 / 54.  0.100
> > Ignoring attempt to set invalid timebase 1/0 for st:0
> > [pcm_s16le @ 0x1c3e1d0] Warning: not compiled with thread support, using thread emulation
> > [pcm_s16le @ 0x1c3e1d0] PCM channels out of bounds
> > [s16le @ 0x1c35550] Failed to open codec in av_find_stream_info
> > [s16le @ 0x1c35550] Could not find codec parameters for stream 0 (Audio: pcm_s16le, 0 channels): unspecified sample format
> > Consider increasing the value for the 'analyzeduration' and 'probesize' options
> > ffmpeg/mips/./tests/data/asynth1.sw: could not find codec parameters
> > Input #0, s16le, from 'ffmpeg/mips/./tests/data/asynth1.sw':
> >   Duration: N/A, bitrate: N/A
> >     Stream #0:0: Audio: pcm_s16le, 0 channels
> > Codec AVOption idct (select IDCT implementation) specified for input file #0 (ffmpeg/mips/./tests/data/asynth1.sw) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some decoder which was not actually used for any stream.
> > Please use -q:a or -q:v, -qscale is ambiguous
> > Output #0, aiff, to 'ffmpeg/mips/./tests/data/lavf/lavf.aif':
> > 
> > 
> > [...]
> > 
> 
> Does it work if you remove this snippet from the configure script?
> 
>     if disabled mipsfpu; then
>         add_ldflags "-msoft-float" &&
>         add_cflags "-msoft-float" &&
>         add_asflags "-msoft-float"
>     fi

yes fate fully passes with that
also you could possibly check for the warning message in configure
if you want to detect this case.
just running an execuatble couldnt be done at configure time

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160125/9941df6e/attachment.sig>


More information about the ffmpeg-devel mailing list