diff options
author | Attila Nagy <attilanagy@google.com> | 2012-04-12 12:50:19 +0300 |
---|---|---|
committer | Attila Nagy <attilanagy@google.com> | 2012-06-20 10:15:24 +0300 |
commit | 5daaa838a62921ad1f5c6e48dc7db180a55fdf3e (patch) | |
tree | ff0e4c2327fb63b76faa6cdd23ac7bacedb21bc6 | |
parent | b178fe7bfb96379d6dda6351b5739378d5c9f4d2 (diff) | |
download | libvpx-5daaa838a62921ad1f5c6e48dc7db180a55fdf3e.tar libvpx-5daaa838a62921ad1f5c6e48dc7db180a55fdf3e.tar.gz libvpx-5daaa838a62921ad1f5c6e48dc7db180a55fdf3e.tar.bz2 libvpx-5daaa838a62921ad1f5c6e48dc7db180a55fdf3e.zip |
Enables building examples with Android NDK
Soft enable runtime cpu detect for armv7-android target, so that it
can be disabled and remove dependency on 'cpufeatures' lib.
Change the arm_cpu_caps implementation selection such that 'no rtcd' takes
precedence over system type.
Switch to use -mtune instead of -mcpu. NDK was complaining about
-mcpu=cortex-a8 conflicting with -march=armv7-a, not sure why.
Add a linker flag to fix some cortex-a8 bug, as suggested by NDK Dev
Guide.
Examples:
Configure for armv7+neon:
./configure --target=armv7-android-gcc \
--sdk-path=/path/to/android/ndk \
--disable-runtime-cpu-detect \
--enable-realtime-only \
--disable-unit-tests
...armv7 w/o neon:
./configure --target=armv7-android-gcc \
--sdk-path=/path/to/android/ndk \
--disable-runtime-cpu-detect \
--enable-realtime-only \
--disable-neon \
--cpu=cortex-a9 \
--disable-unit-tests
Change-Id: I37e2c0592745208979deec38f7658378d4bd6cfa
-rw-r--r-- | build/make/Android.mk | 16 | ||||
-rwxr-xr-x | build/make/configure.sh | 19 | ||||
-rw-r--r-- | vpx_ports/arm_cpudetect.c | 49 |
3 files changed, 53 insertions, 31 deletions
diff --git a/build/make/Android.mk b/build/make/Android.mk index 6fcd4aec3..d54639aa6 100644 --- a/build/make/Android.mk +++ b/build/make/Android.mk @@ -34,8 +34,15 @@ # Application.mk in the jni directory that contains: # APP_ABI := armeabi-v7a # +# By default libvpx will detect at runtime the existance of NEON extension. +# For this we import the 'cpufeatures' module from the NDK sources. +# libvpx can also be configured without this runtime detection method. +# Configuring with --disable-runtime-cpu-detect will assume presence of NEON. +# Configuring with --disable-runtime-cpu-detect --disable-neon will remove any +# NEON dependency. + # To change to building armeabi, run ./libvpx/configure again, but with -# --target=arm5te-android-gcc and and modify the Application.mk file to +# --target=arm5te-android-gcc and modify the Application.mk file to # set APP_ABI := armeabi # # Running ndk-build will build libvpx and include it in your project. @@ -166,7 +173,9 @@ LOCAL_MODULE := libvpx LOCAL_LDLIBS := -llog -LOCAL_STATIC_LIBRARIES := cpufeatures +ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) + LOCAL_STATIC_LIBRARIES := cpufeatures +endif $(foreach file, $(LOCAL_SRC_FILES), $(LOCAL_PATH)/$(file)): vpx_rtcd.h @@ -196,4 +205,7 @@ ifeq ($(CONFIG_VP8_ENCODER), yes) $(LIBVPX_PATH)/vp8/encoder/asm_enc_offsets.c)) endif +ifeq ($(CONFIG_RUNTIME_CPU_DETECT),yes) $(call import-module,cpufeatures) +endif + diff --git a/build/make/configure.sh b/build/make/configure.sh index 575a394ff..9a520a997 100755 --- a/build/make/configure.sh +++ b/build/make/configure.sh @@ -773,17 +773,23 @@ process_common_toolchain() { check_add_asflags --defsym ARCHITECTURE=${arch_int} tune_cflags="-mtune=" if [ ${tgt_isa} == "armv7" ]; then + check_add_cflags -march=armv7-a -mfloat-abi=softfp + check_add_asflags -march=armv7-a -mfloat-abi=softfp + if enabled neon then check_add_cflags -mfpu=neon #-ftree-vectorize check_add_asflags -mfpu=neon fi - check_add_cflags -march=armv7-a -mcpu=cortex-a8 -mfloat-abi=softfp - check_add_asflags -mcpu=cortex-a8 -mfloat-abi=softfp #-march=armv7-a + + if [ -z "${tune_cpu}" ]; then + tune_cpu=cortex-a8 + fi else check_add_cflags -march=${tgt_isa} check_add_asflags -march=${tgt_isa} fi + enabled debug && add_asflags -g asm_conversion_cmd="${source_path}/build/make/ads2gas.pl" ;; @@ -851,12 +857,17 @@ process_common_toolchain() { add_cflags "--sysroot=${alt_libc}" add_ldflags "--sysroot=${alt_libc}" - add_cflags "-I${SDK_PATH}/sources/android/cpufeatures/" + # linker flag that routes around a CPU bug in some + # Cortex-A8 implementations (NDK Dev Guide) + add_ldflags "-Wl,--fix-cortex-a8" enable pic soft_enable realtime_only if [ ${tgt_isa} == "armv7" ]; then - enable runtime_cpu_detect + soft_enable runtime_cpu_detect + fi + if enabled runtime_cpu_detect; then + add_cflags "-I${SDK_PATH}/sources/android/cpufeatures" fi ;; diff --git a/vpx_ports/arm_cpudetect.c b/vpx_ports/arm_cpudetect.c index ebe428df3..ff37ed173 100644 --- a/vpx_ports/arm_cpudetect.c +++ b/vpx_ports/arm_cpudetect.c @@ -32,8 +32,30 @@ static int arm_cpu_env_mask(void) return env && *env ? (int)strtol(env, NULL, 0) : ~0; } +#if !CONFIG_RUNTIME_CPU_DETECT -#if defined(_MSC_VER) +int arm_cpu_caps(void) +{ + int flags; + int mask; + if (!arm_cpu_env_flags(&flags)) + { + return flags; + } + mask = arm_cpu_env_mask(); +#if defined(HAVE_EDSP) + flags |= HAS_EDSP; +#endif +#if defined(HAVE_MEDIA) + flags |= HAS_MEDIA; +#endif +#if defined(HAVE_NEON) + flags |= HAS_NEON; +#endif + return flags & mask; +} + +#elif defined(_MSC_VER) /*For GetExceptionCode() and EXCEPTION_ILLEGAL_INSTRUCTION.*/ #define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN @@ -189,30 +211,7 @@ int arm_cpu_caps(void) return flags & mask; } #endif // defined(__linux__) -#elif !CONFIG_RUNTIME_CPU_DETECT - -int arm_cpu_caps(void) -{ - int flags; - int mask; - if (!arm_cpu_env_flags(&flags)) - { - return flags; - } - mask = arm_cpu_env_mask(); -#if defined(HAVE_EDSP) - flags |= HAS_EDSP; -#endif -#if defined(HAVE_MEDIA) - flags |= HAS_MEDIA; -#endif -#if defined(HAVE_NEON) - flags |= HAS_NEON; -#endif - return flags & mask; -} - #else #error "--enable-runtime-cpu-detect selected, but no CPU detection method " \ - "available for your platform. Reconfigure without --enable-runtime-cpu-detect." + "available for your platform. Reconfigure with --disable-runtime-cpu-detect." #endif |