[FFmpeg-devel] [patch] Option to specify Thumb instructions when building for arm.

David Conrad lessen42
Wed Dec 8 08:18:34 CET 2010

On Dec 7, 2010, at 8:51 AM, Mike Edenfield wrote:

> On 12/7/2010 7:08 AM, Luca Barbato wrote:
>> On 12/07/2010 12:33 AM, Mike Edenfield wrote:
>>> This patch allows the user to use -mthumb to build Thumb 16-bit
>>> instructions instead of -arm, which builds ARM 32-bit instructions.
>>> Using -mthumb instead of -marm also defines __thumb__, which is needed
>>> e.g. when building using the Android native toolchain.
>>> (This patch eliminates the need to supply --extra-cflags to do a thumb
>>> build.)
>> doesn't that break the arm asm completely?
> It builds and run fine here, but I'll be the first to admit I'm in a
> tiny bit over my head.  I'm mostly trying to simplify the configure
> process for ffmpeg by eliminating as many custom CFLAGS options as I
> can.  Its entirely possible that I'm making this way to hard, in which
> case I'd be grateful for someone to clarify for me :)
> The motivation behind the patch is trying to use the Android native
> tools as a cross-compiler.  Trying to build just using the --enable-arm
> support gave me a few problems:
> 1. The system headers supplied by the NDK don't compile:
> /opt/android-ndk-r5/platforms/android-5/arch-arm/usr/include/asm/byteorder.h:
> In function '___arch__swab32':
> /opt/android-ndk-r5/platforms/android-5/arch-arm/usr/include/asm/byteorder.h:25:
> error: expected ')' before ':' token
> I only investigated this problem far enough to figure out that the
> offending asm() statement is behind an #ifndef __thumb__ block.

If you're squeamish about changing system headers (or about telling Android to fix their broken headers; -std=c99 is the flag that breaks them) another option is to add -fasm to ffmpeg cflags.
But you should at least tell them that their headers are broken.

> 2. I get linker warnings about mismatched implementations of
> short-enums.  I guess the default implementation for -marm and -mthumb
> are different.
> 3. By default the NDK builds are -mthumb builds; this means I have to
> specify -mthumb-interwork on my ffmpeg build and/or force my NDK builds
> to be ARM.  I'm not sure what the implications are for either option,
> but I've been assuming that the NDK defaults to Thumb for a reason and
> sticking to that.

-mthumb-interwork only matters for armv4. Which I'm pretty sure Android doesn't support.

> Of course, there are easy workarounds here, such as
> --extra-cflags="-D__thumb__ -mabi=aapcs-linux", but it seems like I'm
> just recreating -mthumb without actually specifying it.

Definitely don't manually define internal compiler macros.

More information about the ffmpeg-devel mailing list