Opened 2 months ago

Last modified 2 months ago

#7796 new defect

Android x86: "error: inline assembly requires more registers than available" when running make

Reported by: ESt Owned by:
Priority: normal Component: build system
Version: git-master Keywords: android
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
When compiling for android x86 with the following command:

./configure --cross-prefix=/home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android- --cc=/home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang --arch=x86 --target-os=android --prefix=android/x86 \
&& make

I'm getting the following errors:

CC      libavcodec/h264_parser.o
CC      libavcodec/h264_picture.o
CC      libavcodec/h264_ps.o
CC      libavcodec/h264_redundant_pps_bsf.o
In file included from libavcodec/h264_cabac.c:37:
In file included from libavcodec/cabac_functions.h:46:
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
        BRANCHLESS_GET_CABAC("%0", "%q0", "(%4)", "%1", "%w1",
        ^
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9CC  libavcodec/h264_refs.o
: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
error: register allocation failed: maximum depth for recoloring reached. Use -fexhaustive-register-search to skip cutoffs
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
error: register allocation failed: maximum depth for recoloring reached. Use -fexhaustive-register-search to skip cutoffs
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available
libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC'
        "movzbl "statep"    , "ret"                                     \n\t"\
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android (5058415 based on r339409) clang version 8.0.2 (https://android.googlesource.com/toolchain/clang 40173bab62ec746213857d083c0e8b0abb568790) (https://android.googlesource.com/toolchain/llvm 7a6618d69e7e8111e1d49dc9e7813767c5ca756a) (based on LLVM 8.0.2svn)
Target: i686-unknown-linux-android21
Thread model: posix
InstalledDir: /home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin
clang: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/h264_cabac-692ca8.c
clang: note: diagnostic msg: /tmp/h264_cabac-692ca8.sh
clang: note: diagnostic msg: 

********************
make: *** [ffbuild/common.mak:60: libavcodec/h264_cabac.o] Error 70
make: *** Waiting for unfinished jobs....

Digging a bit into 'libavcodec/x86/cabac.h' I found that there's a macro named 'HAVE_7REGS' which is defined at libavutil/x86/asm.h:75:

#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))

And is set to true, since HAVE_EBX_AVAILABLE & HAVE_EBP_AVAILABLE are both set to true by the configuration file:


install prefix            android/x86
source path               .
C compiler                /home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang
C library                 bionic
host C compiler           gcc
host C library            glibc
ARCH                      x86 (generic)
big-endian                no
runtime cpu detection     yes
standalone assembly       yes
x86 assembler             nasm
MMX enabled               yes
MMXEXT enabled            yes
3DNow! enabled            yes
3DNow! extended enabled   yes
SSE enabled               yes
SSSE3 enabled             yes
AESNI enabled             yes
AVX enabled               yes
AVX2 enabled              yes
AVX-512 enabled           yes
XOP enabled               yes
FMA3 enabled              yes
FMA4 enabled              yes
i686 features enabled     yes
CMOV is fast              no
EBX available             yes
EBP available             yes
debug symbols             yes
strip symbols             yes
optimize for size         no
optimizations             yes
static                    yes
shared                    no
postprocessing support    no
network support           yes
threading support         pthreads
safe bitstream reader     yes
texi2html enabled         no
perl enabled              yes
pod2man enabled           yes
makeinfo enabled          yes
makeinfo supports HTML    yes

Here's some additional output from the config.log file:

check_inline_asm ebx_available ""::"b"(0)
test_cc
BEGIN /tmp/ffconf.7dLsRDsC/test.c
    1	void foo(void){ __asm__ volatile(""::"b"(0)); }
END /tmp/ffconf.7dLsRDsC/test.c
/home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -std=c11 -fPIE -fomit-frame-pointer -fPIC -c -o /tmp/ffconf.7dLsRDsC/test.o /tmp/ffconf.7dLsRDsC/test.c
check_inline_asm ebx_available "":::"%ebx"
test_cc
BEGIN /tmp/ffconf.7dLsRDsC/test.c
    1	void foo(void){ __asm__ volatile("":::"%ebx"); }
END /tmp/ffconf.7dLsRDsC/test.c
/home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Dstrtod=avpriv_strtod -DPIC -std=c11 -fPIE -fomit-frame-pointer -fPIC -c -o /tmp/ffconf.7dLsRDsC/test.o /tmp/ffconf.7dLsRDsC/test.c

When I set the definition of HAVE_7REGS to the following, it compiles with no problem:

#define HAVE_7REGS (ARCH_X86_64)

So I'm not sure if it's the EBX or EBP tests that are wrong, the definition of the HAVE_7REGS, my configuration or the clang compiler.

How to reproduce:

./configure --cross-prefix=/home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android- --cc=/home/es/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang --arch=x86 --target-os=android --prefix=android/x86 \
&& make

#built on Arch-Linux, NDK r19b

I'm attaching the config.log and the /tmp/h264_cabac-692ca8.sh and /tmp/h264_cabac-692ca8.c below

Attachments (3)

config.log (446.4 KB) - added by ESt 2 months ago.
h264_cabac-692ca8.c (1.7 MB) - added by ESt 2 months ago.
h264_cabac-692ca8.sh (5.2 KB) - added by ESt 2 months ago.

Change History (7)

Changed 2 months ago by ESt

Changed 2 months ago by ESt

Changed 2 months ago by ESt

comment:1 Changed 2 months ago by cehoyos

  • Keywords x86 registers removed

Apart from ‘’compiler bug’’:
I thought that building for i686-android without --disable-asm leads to unusable binaries: Has this changed?

comment:2 Changed 2 months ago by ESt

Oh, I wasn't aware of that, should I close this bug then?

comment:3 Changed 2 months ago by ESt

Btw, if that's the case maybe it'd be better to disable asm by default in the case of android x86, or at least display a warning to the developer

comment:4 Changed 2 months ago by cehoyos

Works fine with --extra-cflags=-fno-integrated-as.

Note: See TracTickets for help on using tickets.