Opened 11 years ago

Closed 10 years ago

#2756 closed defect (fixed)

Compilation fails on ARMv7 with GCC 4.8.1

Reported by: cooper Owned by:
Priority: normal Component: build system
Version: 1.2.1 Keywords:
Cc: Dongwon Kang Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

While compiling FFMpeg 1.2.1 (gentoo ebuild) using GCC 4.8.1 on my Odroid-U2 I get a compilation error.

How to reproduce:
I've set CFLAGS to "-O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard" and enabled NEON. I get the following error during compilation:

armv7a-hardfloat-linux-gnueabi-gcc -I. -I/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DHAVE_AV_CONFIG_H -O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard  -O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -march=armv7-a -std=c99 -fomit-frame-pointer -marm -fPIC -pthread -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -D_REENTRANT -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla  -MMD -MF libavcodec/dct.d -MT libavcodec/dct.o -c -o libavcodec/dct.o /var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dct.c
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dcaenc.c: In function 'encode_init':
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dcaenc.c:227:36: warning: iteration 256u invokes undefined behavior [-Waggressive-loop-optimizations]
         lfe_fir_64i[i] = lfe_fir_64[i] * (1 << 25); //float -> int32_t
                                    ^
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dcaenc.c:226:5: note: containing loop
     for (i = 0; i < 512; i++)
     ^
armv7a-hardfloat-linux-gnueabi-gcc -I. -I/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/ -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -DHAVE_AV_CONFIG_H -O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard  -O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -march=armv7-a -std=c99 -fomit-frame-pointer -marm -fPIC -pthread -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -D_REENTRANT -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -Wdeclaration-after-statement -Wall -Wno-parentheses -Wno-switch -Wno-format-zero-length -Wdisabled-optimization -Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wwrite-strings -Wtype-limits -Wundef -Wmissing-prototypes -Wno-pointer-to-int-cast -Wstrict-prototypes -O3 -pipe -march=armv7-a -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=hard -fno-math-errno -fno-signed-zeros -fno-tree-vectorize -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=return-type -Werror=vla  -MMD -MF libavcodec/dct32_fixed.d -MT libavcodec/dct32_fixed.o -c -o libavcodec/dct32_fixed.o /var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dct32_fixed.c
In file included from /var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dcadec.c:51:0:
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dcadec.c: In function 'dca_xbr_parse_frame':
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/arm/dca.h:37:5: error: can't find a register in class 'CORE_REGS' while reloading 'asm'
     __asm__ ("smmul   %8,  %14, %18           \n"
     ^
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/arm/dca.h:37:5: error: 'asm' operand has impossible constraints
/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1/libavcodec/dcadec.c:1891: confused by earlier errors, bailing out
make: *** [libavcodec/dcadec.o] Error 1
make: *** Waiting for unfinished jobs....
 * ERROR: media-video/ffmpeg-1.2.1 failed (compile phase):
 *   emake failed
 * 
 * If you need support, post the output of `emerge --info '=media-video/ffmpeg-1.2.1'`,
 * the complete build log and the output of `emerge -pqv '=media-video/ffmpeg-1.2.1'`.
 * The complete build log is located at '/var/tmp/portage/media-video/ffmpeg-1.2.1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/media-video/ffmpeg-1.2.1/temp/environment'.
 * Working directory: '/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1_build'
 * S: '/var/tmp/portage/media-video/ffmpeg-1.2.1/work/ffmpeg-1.2.1'

I've tried compiling without NEON support, making sure to specify -mfpu=vfpv3 in the CFLAGS, but that changed nothing (I did verify that FFMpeg configured itself with NEON support disabled).
I also tried, because of the '-Waggressive-loop-optimizations' warning, to compile with '-fno-aggressive-loop-optimizations' but that didn't change anything either.

What's interesting, though, is that when I enabled THUMB support (-mthumb) compilation completes without any issues and I get a perfectly functioning FFMpeg.

FFMpeg compiles just fine, for all these CFLAGS variations, on GCC 4.7.3 as well as GCC 4.6.4.

Change History (9)

comment:1 by Carl Eugen Hoyos, 11 years ago

Please test current git head and please post your configure line, then run "make ffmpeg" (and see the compilation error), then run "make V=1" and post the console output of the last command. (Please do not post the console output of the first make call.)

comment:2 by cooper, 11 years ago

Test against GIT HEAD results in succesful compilation.
Whatever was going on in 1.2.1, it's apparently been fixed since.

This issue can be closed.

comment:3 by Carl Eugen Hoyos, 11 years ago

Could you find out which change fixed compilation? We could backport the change to release/1.2.

comment:4 by Dongwon Kang, 10 years ago

I found that this happens in gcc 4.8 on Android. There is no 'CORE_REGS' in 4.8.
https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8

in reply to:  4 comment:5 by Carl Eugen Hoyos, 10 years ago

Cc: Dongwon Kang added

Replying to dwkang:

I found that this happens in gcc 4.8 on Android. There is no 'CORE_REGS' in 4.8.
https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.8

Then please find out which commit fixed the issue in newer versions, so we can fix it in future 1.2 releases.

comment:6 by cooper, 10 years ago

Given the discovered reasoning, I'm guessing this one:
https://github.com/FFmpeg/FFmpeg/commit/8067f55edf3719182aed6e5b57b7863889f80218

comment:7 by Carl Eugen Hoyos, 10 years ago

Could you test if backporting that patch to origin/release/1.2 fixes the compilation problem?

$ git checkout origin/release/1.2
$ git cherry-pick -x 8067f55e

I have tested that the backport works, I can't test compilation here.

comment:8 by Dongwon Kang, 10 years ago

Verified the patch resolves the issue.

comment:9 by Carl Eugen Hoyos, 10 years ago

Resolution: fixed
Status: newclosed

Will be fixed in FFmpeg 1.2.6, thank you for the report!

Note: See TracTickets for help on using tickets.