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

Aurelien Jarno <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <[email protected]>
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 <[email protected]>, [email protected]
> 
> 
> 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
> TEST: 0x1FFFF
> 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
sequencing).

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.