Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 411807 - media-video/ffmpeg-0.10.2 - In function ‘get_cabac_noinline’: libavcodec/x86/cabac.h:93:5: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
Summary: media-video/ffmpeg-0.10.2 - In function ‘get_cabac_noinline’: libavcodec/x86/...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: x86 Linux
: Normal normal (vote)
Assignee: Gentoo Media-video project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-04-12 23:48 UTC by Alexander Bezrukov
Modified: 2012-04-17 21:30 UTC (History)
1 user (show)

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


Attachments
emerge --info (emerge.info,4.91 KB, text/plain)
2012-04-12 23:48 UTC, Alexander Bezrukov
Details
build.log (build.log,29.61 KB, text/plain)
2012-04-14 17:21 UTC, Alexander Bezrukov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Bezrukov 2012-04-12 23:48:59 UTC
Created attachment 308709 [details]
emerge --info

media-video/ffmpeg-0.10.2 fails to compile with gcc-4.5.3 on x86 with:

In file included from libavcodec/cabac.c:32:0:
libavcodec/cabac_functions.h: In function ‘get_cabac_noinline’:
libavcodec/x86/cabac.h:93:5: error: can't find a register in class ‘GENERAL_REGS’ while reloading ‘asm’
libavcodec/x86/cabac.h:93:5: error: ‘asm’ operand has impossible constraints

The problematic part of code is:
static av_always_inline int get_cabac_inline_x86(CABACContext *c,
                                                 uint8_t *const state)
{
    int bit, tmp;

    __asm__ volatile(
        BRANCHLESS_GET_CABAC("%0", "(%5)", "%1", "%w1", "%2",
                             "%3", "%b3", "%4")
        :"=&r"(bit), "+&r"(c->low), "+&r"(c->range), "=&q"(tmp),
         "+m"(c->bytestream)
        :"r"(state)
        : "%"REG_c, "memory"
    );
    return bit & 1;
}


This bug is very much resembling the following
https://bugs.gentoo.org/show_bug.cgi?id=71360

According to the upstream FAQ (see doc/faq.texi:71), this is a known bug in gcc:
@chapter Compilation

@section @code{error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'}

This is a bug in gcc. Do not report it to us. Instead, please report it to
the gcc developers. Note that we will not add workarounds for gcc bugs.

Also note that (some of) the gcc developers believe this is not a bug or
not a bug they should fix:
@url{http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203}.
Then again, some of them do not know the difference between an undecidable
problem and an NP-hard problem...

As a minor note, the compiler issues a lot of "Warning: missing operand; zero assumed" messages for apparently clean assembly code.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2012-04-14 05:54:43 UTC
Please attach the entire build log to this bug report.
Comment 2 Alexander Bezrukov 2012-04-14 17:21:42 UTC
Created attachment 308935 [details]
build.log

Jeroen, here you are.

My CPU (since -march=native):

>cat /proc/cpuinfo 
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 15
model name	: Intel(R) Core(TM)2 Duo CPU     T5670  @ 1.80GHz
stepping	: 13
microcode	: 0xa3
cpu MHz		: 1200.000
cache size	: 2048 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
apicid		: 0
initial apicid	: 0
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 10
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc arch_perfmon pebs bts aperfmperf pni dtes64 monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm ida dts
bogomips	: 3590.47
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

<SNIP>
Comment 3 Alexis Ballier gentoo-dev 2012-04-16 11:21:14 UTC
CFLAGS="-combine -march=native -O2 -pipe -fomit-frame-pointer -finline-functions-called-once -ftree-vectorize -funroll-loops"

please try with sane cflags first

esp. whats this -combine cflag ?
Comment 4 Alexander Bezrukov 2012-04-16 13:38:29 UTC
(In reply to comment #3)
> CFLAGS="-combine -march=native -O2 -pipe -fomit-frame-pointer
> -finline-functions-called-once -ftree-vectorize -funroll-loops"
> 
> please try with sane cflags first
> 
> esp. whats this -combine cflag ?

Alexis, sorry about forgetting to mention this at first. I tried it even before reporting the bug. I also tried with just "-O2" and "-O0" and even without passing any flags, among others. I also tried -march=generic, which theoretically might change the size of the coloring problem.

The -combine flag enables IMO. For a well-formed program, if a build system supplies several filenames at once to the compiler, it may result in additional optimizations. Programs which violate the ODR may not compile (but they are not expected to, anyway). Besides that I don't see this flag insane, this flag has nothing to do with this (register allocation) problem, at least because files are supplied one by one by the make system.
Comment 5 Alexis Ballier gentoo-dev 2012-04-16 14:27:16 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > CFLAGS="-combine -march=native -O2 -pipe -fomit-frame-pointer
> > -finline-functions-called-once -ftree-vectorize -funroll-loops"
> > 
> > please try with sane cflags first
> > 
> > esp. whats this -combine cflag ?
> 
> Alexis, sorry about forgetting to mention this at first. I tried it even
> before reporting the bug. I also tried with just "-O2" and "-O0" and even
> without passing any flags, among others. I also tried -march=generic, which
> theoretically might change the size of the coloring problem.
> 
> The -combine flag enables IMO. For a well-formed program, if a build system
> supplies several filenames at once to the compiler, it may result in
> additional optimizations. Programs which violate the ODR may not compile
> (but they are not expected to, anyway). Besides that I don't see this flag
> insane, this flag has nothing to do with this (register allocation) problem,
> at least because files are supplied one by one by the make system.

ok, i asked about that flag because i didnt know about it.

ftree-vectorize and funroll-loops were the ones i called 'not sane' :)

please go to ffmpeg build dir and type 'make V=1' to get the exact compiler line executed and making the build fail.
Comment 6 Alexis Ballier gentoo-dev 2012-04-16 14:29:13 UTC
(In reply to comment #4)
> The -combine flag enables IMO. For a well-formed program, if a build system
> supplies several filenames at once to the compiler, it may result in
> additional optimizations. Programs which violate the ODR may not compile
> (but they are not expected to, anyway). Besides that I don't see this flag
> insane, this flag has nothing to do with this (register allocation) problem,
> at least because files are supplied one by one by the make system.

btw:
$ gcc --version
gcc (Gentoo 4.6.2 p1.4, pie-0.5.0) 4.6.2
$ gcc -combine
gcc: error: unrecognized option ‘-combine’
Comment 7 Alexander Bezrukov 2012-04-17 21:30:13 UTC
Alexis, shame on me!

I am closing this bug as INVALID. The culprit was that I made a typo in one rsync cron job and managed by mistake to rsync /etc/portage/env from a machine with a different (64-bit) architecture, which contained some settings and workarounds aimed at a specific Family/Stepping of Opteron processor from a host where this was important. Shame, shame!

I am sorry about creating so much unnecessary noise!