[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#800318: gcc-5: [mips,mipsel] regression: miscompilation caused by -fexpensive-optimizations

On 2015-09-27 20:37, Andreas Cadhalpun wrote:
> Package: gcc-5
> Version: 5.2.1-17
> Severity: serious
> Justification: causes ffmpeg to FTBFS
> Control: affects -1 ffmpeg
> X-Debbugs-Cc: Aurelien Jarno <aurel32@debian.org>, debian-mips@lists.debian.org
> Dear Maintainer,
> ffmpeg 7:2.8-1 failed to build on mips/mipsel due to test failures.
> I investigated the problem and it turns out to be caused by a compiler bug
> that can be avoided by using '-fno-expensive-optimizations'.
> Attached is a reduced test case:
> $ ls
> Makefile  main.c  test.c
> $ make
> cc -fPIC -O2 -fno-expensive-optimizations -c -o working.o test.c
> cc -shared -o libworking.so working.o
> cc -o working main.c -L. -lworking
> cc -fPIC -O2 -c -o broken.o test.c
> cc -shared -o libbroken.so broken.o
> cc -o broken main.c -L. -lbroken
> LD_LIBRARY_PATH=. ./working || true
> TEST: 0x12A15
> working
> LD_LIBRARY_PATH=. ./broken || true
> broken

Thanks for the detailed testcase. I have been able to reproduce the
issue on mipsel, but not on mips.

> This works correctly with gcc-5 5.2.1-16, so it is a regression in 5.2.1-17.
> The changelog reveals:
>   [ Aurelien Jarno ]
>   * Use --with-mips-plt on mips*.
>   * Build for R2 ISA on mips, mips64 and mips64el.
>   * Optimize for R2 ISA on mipsel.
>   * Only apply mips-fix-loongson2f-nop on mipsel.
> I assume one of these changes is responsible for this regression.

Indeed. At least on mipsel the issue is due to the use of
-mtune=mips32r2 by default. I guess the best is to change it back to
-mtune=mips32 until we better understand the issue.

Does someone have time to look at the issue more in details? The
generated code is quite different between -mtune=mips32 and
-mtune=mips32r2 (not in terms of instructions, but in terms of

As for mips, given I am not able to reproduce the issue, my guess is
that it's due to the switch to -march=mips32r2, but I currently have
no way to make sure.


Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

Reply to: