From 107b9c70d04c381d5517582d67925a29eac6eac4 Mon Sep 17 00:00:00 2001 From: Tomasz Figa Date: Tue, 18 Jul 2017 16:20:52 +0900 Subject: [PATCH] gallium: auxiliary: Fix standalone Android build of u_cpu_detect (v2) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit 463b7d0332c5("gallium: Enable ARM NEON CPU detection.") introduced CPU feature detection based Android cpufeatures library. Unfortunately it also added an assumption that if PIPE_OS_ANDROID is defined, the library is also available, which is not true for the standalone build without using Android build system. Fix it by defining HAS_ANDROID_CPUFEATURES in Android.mk and replacing respective #ifdefs to use it instead. v2: - Add a comment explaining why the separate flag is needed (Emil). Signed-off-by: Tomasz Figa Reviewed-by: Marek Olšák Reviewed-by: Emil Velikov --- src/gallium/auxiliary/Android.mk | 1 + src/gallium/auxiliary/util/u_cpu_detect.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/Android.mk b/src/gallium/auxiliary/Android.mk index 356390d..2693838 100644 --- a/src/gallium/auxiliary/Android.mk +++ b/src/gallium/auxiliary/Android.mk @@ -50,6 +50,7 @@ LOCAL_MODULE := libmesa_gallium LOCAL_STATIC_LIBRARIES += libmesa_nir LOCAL_WHOLE_STATIC_LIBRARIES += cpufeatures +LOCAL_CFLAGS += -DHAS_ANDROID_CPUFEATURES # generate sources LOCAL_MODULE_CLASS := STATIC_LIBRARIES diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c index 76115bf..3d6ccb5 100644 --- a/src/gallium/auxiliary/util/u_cpu_detect.c +++ b/src/gallium/auxiliary/util/u_cpu_detect.c @@ -67,7 +67,7 @@ #include #endif -#if defined(PIPE_OS_ANDROID) +#if defined(HAS_ANDROID_CPUFEATURES) #include #endif @@ -304,7 +304,14 @@ PIPE_ALIGN_STACK static inline boolean sse2_has_daz(void) static void check_os_arm_support(void) { -#if defined(PIPE_OS_ANDROID) + /* + * On Android, the cpufeatures library is preferred way of checking + * CPU capabilities. However, it is not available for standalone Mesa + * builds, i.e. when Android build system (Android.mk-based) is not + * used. Because of this we cannot use PIPE_OS_ANDROID here, but rather + * have a separate macro that only gets enabled from respective Android.mk. + */ +#if defined(HAS_ANDROID_CPUFEATURES) AndroidCpuFamily cpu_family = android_getCpuFamily(); uint64_t cpu_features = android_getCpuFeatures(); -- 2.7.4