[FFmpeg-devel] [patch] Option to specify Thumb instructions when building for arm.
Martin Storsjö
martin
Wed Dec 8 09:47:19 CET 2010
On Tue, 7 Dec 2010, Mike Edenfield wrote:
> 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.
This is a header bug, as Luca B said, just replace asm() with __asm__().
The history for this bug is something like this: This is originally a
kernel internal header, where it is ok to have it just as asm(). (Someone
discussed changing some similar occurrances to __asm__ on LKML around 2005
or so, but it was turned down, since these headers are internal to the
kernel, where it shouldn't matter.) Glibc doesn't ship this header visible
to userland programs, since it has everything it needs anyway. But in
bionic, they've picked a lot of kernel internal headers and used them as
part of the userland visible headers, where this suddenly is an issue.
FWIW, I submitted this change to Android now, at
https://review.source.android.com/19404. I'm not sure if this request will
be accepted though, since it's an automatically generated header - instead
I'll probably have to fix the scripts that generate it.
> 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.
>
> 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.
Yes, you used to have to add a whole bunch of Android specific cflags for
things to work as intended. In the newly released NDK r5 (released the
other day), there's a new toolchain named arm-linux-androideabi-4.4.3,
where none of these extra flags are necessary, it defaults to producing
binaries compatible with what android expects.
// Martin
More information about the ffmpeg-devel
mailing list