Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 506206 - media-video/ffmpeg-1.2.6 with sys-devel/gcc-4.8.2 on hardened - In function ‘dirac_get_arith_bit’: .../work/ffmpeg-1.2.6/libavcodec/dirac_arith.h:141:5: error: ‘asm’ operand has impossible constraints
Summary: media-video/ffmpeg-1.2.6 with sys-devel/gcc-4.8.2 on hardened - In function ‘...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-30 00:30 UTC by Anthoine Bourgeois
Modified: 2014-04-13 21:01 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge.info (emerge.info,6.17 KB, text/plain)
2014-03-30 00:31 UTC, Anthoine Bourgeois
Details
build.log (build.log,826.70 KB, text/plain)
2014-03-30 00:31 UTC, Anthoine Bourgeois
Details
emerge -pqv '=media-video/ffmpeg-1.2.6::gentoo' (emerge.pqv,657 bytes, text/plain)
2014-03-30 00:32 UTC, Anthoine Bourgeois
Details
environment (environment,89.53 KB, text/plain)
2014-03-30 00:32 UTC, Anthoine Bourgeois
Details
ffmpeg-1.2.6-r1.ebuild.patch (ffmpeg-1.2.6-r1.ebuild.patch,955 bytes, patch)
2014-04-04 22:15 UTC, Anthoine Bourgeois
Details | Diff
disable -fstack-check (ffmpeg_fnostackcheck.patch,774 bytes, patch)
2014-04-05 13:28 UTC, Magnus Granberg
Details | Diff
Use HAVE_6REGS to protect the asm code (ffmpeg-1.2.6-dirac_arith_h_6regs.patch,712 bytes, patch)
2014-04-08 14:06 UTC, Anthoine Bourgeois
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anthoine Bourgeois 2014-03-30 00:30:24 UTC
Hi,

I try to emerge the ffmpeg-1.2.6 lib with gcc-4.8.2 and it fails to build:
In file included from /var/tmp/portage/media-video/ffmpeg-1.2.6/work/ffmpeg-1.2.6/libavcodec/diracdec.c:35:0:
/var/tmp/portage/media-video/ffmpeg-1.2.6/work/ffmpeg-1.2.6/libavcodec/dirac_arith.h: In function ‘dirac_get_arith_bit’:
/var/tmp/portage/media-video/ffmpeg-1.2.6/work/ffmpeg-1.2.6/libavcodec/dirac_arith.h:141:5: error: ‘asm’ operand has impossible constraints
     __asm__(
     ^
make: *** [libavcodec/diracdec.o] Error 1

First I think that the issue was the same as bug #504272 but I try to apply env as describe in comment #1 but it doesn't help. I try with i686-pc-linux-gnu-4.8.2 or i686-pc-linux-gnu-4.8.2-hardenednopie without luck. i686-pc-linux-gnu-4.7.3 or i686-pc-linux-gnu-4.8.2-vanilla works fine.

Reproducible: Always
Comment 1 Anthoine Bourgeois 2014-03-30 00:31:00 UTC
Created attachment 373864 [details]
emerge.info
Comment 2 Anthoine Bourgeois 2014-03-30 00:31:33 UTC
Created attachment 373866 [details]
build.log
Comment 3 Anthoine Bourgeois 2014-03-30 00:32:00 UTC
Created attachment 373868 [details]
emerge -pqv '=media-video/ffmpeg-1.2.6::gentoo'
Comment 4 Anthoine Bourgeois 2014-03-30 00:32:27 UTC
Created attachment 373870 [details]
environment
Comment 5 Anthoine Bourgeois 2014-04-02 12:41:41 UTC
The code who produce the error is in ffmpeg-1.2.6/libavcodec/dirac_arith.h:141 :
 __asm__(
        "cmpl   %5, %4 \n\t"
        "setae  %b0    \n\t"
        "cmovb  %3, %2 \n\t"
        "cmovb  %5, %1 \n\t"
        : "+q"(bit), "+r"(range), "+r"(low)
        : "r"(c->low), "r"(c->low>>16),
          "r"(range_times_prob)
    );

This code use 6 registers : eax, ecx, edx, esi, edi, ebp (ebx is used by PIC). The gcc-4.8.2 introduce -fstack-check to hardened configuration and this option disable -fomit-frame-pointer then ebp is used as frame pointer and only 5 registers are available.

Should an implicit option (stack-check) of the default configuration silently takes over and masks an explicit option on the command line (omit-frame-pointer) ?

With -fstack-check=no the code builds.
Comment 6 Anthoine Bourgeois 2014-04-04 19:53:50 UTC
See Also:
https://bugs.gentoo.org/show_bug.cgi?id=471756
Comment 7 Anthoine Bourgeois 2014-04-04 22:15:57 UTC
Created attachment 374262 [details, diff]
ffmpeg-1.2.6-r1.ebuild.patch

ebuild proposal to fix this issue.
Comment 8 Magnus Granberg gentoo-dev 2014-04-05 13:28:10 UTC
Created attachment 374296 [details, diff]
disable -fstack-check

On hardened >=gcc 4.8.0 we enable -fstack-check and it need extra register to work and some asm code is allready using all so we disable it.
Comment 9 Magnus Granberg gentoo-dev 2014-04-07 20:23:01 UTC
okay to applay the patch?
Comment 10 Alexis Ballier gentoo-dev 2014-04-08 07:09:33 UTC
(In reply to Magnus Granberg from comment #9)
> okay to applay the patch?

no; ffmpeg has 'HAVE_6REGS' and 'HAVE_7REGS' macro in libavutil/x86/asm.h so, if you cannot improve the asm not to require 6 regs, make the usage and compilation of that code conditional to one of these macros

and of course, send the patch upstream
Comment 11 Anthoine Bourgeois 2014-04-08 14:06:17 UTC
Created attachment 374546 [details, diff]
Use HAVE_6REGS to protect the asm code

I send the patch upstream. Note all versions are affected.
Comment 12 Anthoine Bourgeois 2014-04-09 12:16:17 UTC
Upstream : https://trac.ffmpeg.org/ticket/3540
A mail is also sent on the ffmpeg-devel mailing list.
Comment 13 Anthoine Bourgeois 2014-04-09 19:08:08 UTC
Fixed upstream in d8ab7f31 .
Comment 14 Alexis Ballier gentoo-dev 2014-04-10 18:12:56 UTC
(In reply to Anthoine Bourgeois from comment #13)
> Fixed upstream in d8ab7f31 .

thanks! applied to 1.2.6
Comment 15 Anthoine Bourgeois 2014-04-11 06:49:34 UTC
(In reply to Alexis Ballier from comment #14)
> thanks! applied to 1.2.6

2.2.1 is also affected.
Comment 16 Alexis Ballier gentoo-dev 2014-04-11 17:20:26 UTC
(In reply to Anthoine Bourgeois from comment #15)
> (In reply to Alexis Ballier from comment #14)
> > thanks! applied to 1.2.6
> 
> 2.2.1 is also affected.

are you sure ?
your patch seems to be in there
Comment 17 Anthoine Bourgeois 2014-04-13 21:01:59 UTC
(In reply to Alexis Ballier from comment #16)
> (In reply to Anthoine Bourgeois from comment #15)
> > (In reply to Alexis Ballier from comment #14)
> > > thanks! applied to 1.2.6
> > 
> > 2.2.1 is also affected.
> 
> are you sure ?
> your patch seems to be in there

No, your right, sorry.