Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 901099

Summary: media-video/ffmpeg-4.4.3[abi_x86_32]: fails with error: inline assembly requires more registers than available
Product: Gentoo Linux Reporter: Alfred Persson <cat>
Component: Current packagesAssignee: Gentoo Media-video project <media-video>
Status: RESOLVED FIXED    
Severity: normal CC: ninpo, sam
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=900937
https://trac.ffmpeg.org/ticket/8903
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257124
https://bugs.gentoo.org/show_bug.cgi?id=578802
https://bugs.gentoo.org/show_bug.cgi?id=733556
https://bugs.gentoo.org/show_bug.cgi?id=772854
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 408963    
Attachments: build.log
emerge --info

Description Alfred Persson 2023-03-13 22:42:18 UTC
This is was hit on a default/linux/amd64/17.1/systemd/clang/merged-usr system. But looking at the forum post it seems to be a problem on amd64/gcc as well.

Reproducible: Always

Steps to Reproduce:
1. emerge media-video/ffmpeg-4.4.3 with USE=abi_x86_32
Actual Results:  
In file included from src/libavcodec/hevc_cabac.c:27:
In file included from src/libavcodec/cabac_functions.h:47:
src/libavcodec/x86/cabac.h:195:9: error: inline assembly requires more registers than available
        BRANCHLESS_GET_CABAC("%0", "%q0", "(%4)", "%1", "%w1",

Expected Results:  
compile without error.

https://forums.gentoo.org/viewtopic-t-1162301.html
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257124: here it seems to be a clang specific bug but looking at the first link this does seem to affect gcc too.
Comment 1 Alfred Persson 2023-03-13 22:44:19 UTC
Created attachment 857537 [details]
build.log
Comment 2 Alfred Persson 2023-03-13 22:45:59 UTC
Created attachment 857539 [details]
emerge --info
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-03-15 01:00:45 UTC
Suspect this is actually the same as bug 900937 but with a different (better) error message.

Let's use bug 900937 for the GCC hang (which is wrong even on invalid input) and this bug for ffmpeg failing to build with clang (and likely gcc once bug 900937 is fixed).
Comment 4 Larry the Git Cow gentoo-dev 2023-03-15 02:15:52 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=60b38d402d8674ea08c9b69cf3147e0b92ab87c2

commit 60b38d402d8674ea08c9b69cf3147e0b92ab87c2
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-03-15 02:13:59 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-03-15 02:14:48 +0000

    media-video/ffmpeg: fix build on register-starved x86
    
    Newer compilers may optimise such that < 7 registers are free on 32-bit x86
    and then we get an "invalid asm" error. This is https://bugs.gentoo.org/901099
    and https://trac.ffmpeg.org/ticket/8903.
    
    Making matters worse, GCC sometimes hangs on invalid asm, so this also
    mitigates a hang with e.g. -O3 -march=znver1. See https://bugs.gentoo.org/900937
    and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137.
    
    In future, we may want to adjust the definition of HAVE_7REGS to just exclude
    32-bit x86, but that's a big sledgehammer, so let's avoid it for now until we have
    a reply on the upstream ffmpeg bug.
    
    Thanks to Ninpo.
    
    Bug: https://trac.ffmpeg.org/ticket/8903
    Bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137
    Bug: https://bugs.gentoo.org/900937
    Closes: https://bugs.gentoo.org/901099
    Signed-off-by: Sam James <sam@gentoo.org>

 media-video/ffmpeg/ffmpeg-4.4.3.ebuild             |  3 ++-
 media-video/ffmpeg/ffmpeg-5.1.2-r1.ebuild          |  3 ++-
 media-video/ffmpeg/ffmpeg-6.0.ebuild               |  3 ++-
 .../ffmpeg-4.4.3-get_cabac_inline_x86-32-bit.patch | 24 +++++++++++++++++++++
 .../ffmpeg-5.1.2-get_cabac_inline_x86-32-bit.patch | 25 ++++++++++++++++++++++
 5 files changed, 55 insertions(+), 3 deletions(-)