gallium: auxiliary: Fix standalone Android build of u_cpu_detect (v2)
authorTomasz Figa <tfiga@chromium.org>
Tue, 18 Jul 2017 07:20:52 +0000 (16:20 +0900)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 19 Jul 2017 12:28:23 +0000 (13:28 +0100)
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 <tfiga@chromium.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
src/gallium/auxiliary/Android.mk
src/gallium/auxiliary/util/u_cpu_detect.c

index 356390dfde6f9726df5e426afbfa37417d64376b..26938384fb22fb0e760aa46ecca635730be7b2b2 100644 (file)
@@ -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
index 76115bf8d55d82890011a25c744fd558392e9ade..3d6ccb58223dcfeec811c91777526b9194030060 100644 (file)
@@ -67,7 +67,7 @@
 #include <unistd.h>
 #endif
 
-#if defined(PIPE_OS_ANDROID)
+#if defined(HAS_ANDROID_CPUFEATURES)
 #include <cpu-features.h>
 #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();