Opened 4 years ago
Closed 20 months ago
#8903 closed defect (fixed)
mingw-w64 clang i686 "inline assembly requires more registers than available"
Reported by: | Christopher Degawa | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | build system |
Version: | git-master | Keywords: | windows, clang, 32-bit, linux, gcc |
Cc: | ccom@randomderp.com, Sam James, Ninpo | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
On windows with a mingw-w64 clang targeting i686 obtained through msys2's pacman by installing the "mingw32/mingw-w64-i686-clang" version 10.0.1-1 package, trying to compile "libavcodec/hevc_cabac.o" will result in
CC libavcodec/hevc_cabac.o D:/mabs/build/test-ffmpeg/libavcodec/hevc_cabac.c:37:21: warning: variable 'num_bins_in_se' is not needed and will not be emitted [-Wunneeded-internal-declaration] static const int8_t num_bins_in_se[] = { ^ In file included from D:/mabs/build/test-ffmpeg/libavcodec/hevc_cabac.c:27: In file included from D:/mabs/build/test-ffmpeg/libavcodec/cabac_functions.h:46: D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available BRANCHLESS_GET_CABAC("%0", "%q0", "(%4)", "%1", "%w1", ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:193:9: error: inline assembly requires more registers than available D:/mabs/build/test-ffmpeg/libavcodec/x86/cabac.h:143:9: note: expanded from macro 'BRANCHLESS_GET_CABAC' "movzbl "statep" , "ret" \n\t"\ ^ 1 warning and 11 errors generated. make: *** [/build/test-ffmpeg/ffbuild/common.mak:67: libavcodec/hevc_cabac.o] Error 1
the error message itself looks pretty much exactly like https://trac.ffmpeg.org/ticket/7796, but since that one seems to specifically be tracking android x86 and I haven't gotten a response on if I should append to that or create a new issue, I decided to make new issue.
The commit I have tested this on is https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/e71d73b09652f4fc96e512a7d6d4c2ab41860f27
head part of configure output
install prefix /usr/local source path /home/user/test-ffmpeg C compiler clang C library mingw64 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 w32threads safe bitstream reader yes texi2html enabled no perl enabled yes pod2man enabled yes makeinfo enabled yes makeinfo supports HTML yes
I can attach the ffbuild/config.log if requested
How to reproduce:
- on a Windows machine or VM, download msys2, then run inside msys2.exe
pacman -Syu --noconfirm pacman -Suu --noconfirm # clang and its deps are quite huge already, 2.5 GiB installed size as reported by pacman pacman -S --needed --noconfirm mingw-w64-i686-clang git base-devel
- Then, run the following inside mingw32.exe
git clone --branch master https://github.com/FFmpeg/FFmpeg.git test-ffmpeg mkdir test-ffmpeg/clang-build && cd test-ffmpeg/clang-build ../configure --cc="clang" --cxx="clang++" make libavcodec/hevc_cabac.o
the clang line from make V=1
clang -I. -I/home/cddeg/test-ffmpeg/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DZLIB_CONST -DHAVE_AV_CONFIG_H -DBUILDING_avcodec -std=c11 -fomit-frame-pointer -I/mingw32/include -g -Wdeclaration-after-statement -Wall -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -Wempty-body -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wno-pointer-sign -Wno-unused-const-variable -Wno-bool-operation -Wno-char-subscripts -O3 -fno-math-errno -fno-signed-zeros -Qunused-arguments -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -MMD -MF libavcodec/hevc_cabac.d -MT libavcodec/hevc_cabac.o -c -o libavcodec/hevc_cabac.o /home/cddeg/test-ffmpeg/libavcodec/hevc_cabac.c
I am not sure how to try to reproduce this on a Linux machine with a clang cross compiler as I do not have any experience doing cross-compilation and trying to use mstorsjo/llvm-mingw resulted in a failure on my part to understand how to use it, and it doesn't seem like there's an easy to follow guide for cross-compiling ffmpeg with clang.
Attempting to use the post-processed source file using -E -P
with both 32-bit gcc and clang results in gcc compiling successfully, but clang failing.
I've tried extracting the "get_cabac_inline_x86" function and the necessary components needed to compile it, along with making it non-static and non-inline and compiling just that function with clang and gcc, but in the isolated function case, both clang and gcc compile the source file without error and I see the assembly in the disassembly of the object file, which makes me guess it might be related to inlining, etc, but I am not a compiler expert.
Change History (10)
comment:1 by , 4 years ago
Cc: | added |
---|
comment:2 by , 4 years ago
comment:3 by , 4 years ago
Priority: | normal → minor |
---|
demoting to minor since I doubt clang + 32-bit + windows is a common enough configuration
follow-up: 5 comment:4 by , 2 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed a while ago for 32-bit clang, although now it's popping up for 32-bit gcc as well
comment:5 by , 21 months ago
Replying to Christopher Degawa:
Fixed a while ago for 32-bit clang, although now it's popping up for 32-bit gcc as well
gcc-12 and gcc-13 are having the same issue in latest releases with CFLAGS -O3 -march=znver1 (presumably also znver2-4) when building with -m32 for 32 bit binaries.
To that end can this be reopened? It appears to be that the number of registers just are not available at compile time with specific CPU optimisations in place, as per this comment at gcc:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137#c5
comment:6 by , 21 months ago
Keywords: | linux gcc added |
---|---|
Priority: | minor → normal |
Resolution: | fixed |
Status: | closed → reopened |
comment:7 by , 21 months ago
Indeed, hitting this on Linux with both GCC and Clang.
With Clang 15: https://bugs.gentoo.org/901099
With GCC 12/13: either this error or a hang (see https://bugs.gentoo.org/900937)
Upstream GCC bug for the hang (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137) says this is really an issue on the asm side, so the error is legitimate: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137#c5.
comment:8 by , 21 months ago
Cc: | added |
---|
comment:9 by , 21 months ago
Cc: | added |
---|
comment:10 by , 20 months ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Should have been fixed by 182663a58a7a099e02e76da3b0f96d63e5c26a6d.
Applying https://gist.github.com/1480c1/86830546ed555b50f91a023100e526a9 seems to allow it to compile