[Mesa-dev] [PATCH 5/6] android: build x86(-64) assembly for Android 5.0

Chih-Wei Huang cwhuang at android-x86.org
Fri Apr 3 14:01:25 PDT 2015


Android 5.0 changed HOST_ARCH to x86_64 that broke the asm
building rules. The patch fix the rules to build asm for both
x86 and x86_64 targets.

Note mesa_gen_matypes is built for 32-bit only.

Signed-off-by: Chih-Wei Huang <cwhuang at linux.org.tw>
---
 Android.common.mk                    | 9 +++++----
 Android.mk                           | 2 +-
 src/mapi/Android.mk                  | 2 ++
 src/mesa/Android.gen.mk              | 2 --
 src/mesa/Android.libmesa_dricore.mk  | 3 +++
 src/mesa/Android.libmesa_st_mesa.mk  | 3 +++
 src/mesa/Android.mesa_gen_matypes.mk | 3 +--
 src/mesa/main/imports.h              | 6 +++---
 8 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/Android.common.mk b/Android.common.mk
index edf52d6..0ca6d13 100644
--- a/Android.common.mk
+++ b/Android.common.mk
@@ -61,10 +61,11 @@ LOCAL_CFLAGS += \
 
 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
 ifeq ($(TARGET_ARCH),x86)
-LOCAL_CFLAGS += \
-	-DUSE_X86_ASM \
-	-DHAVE_DLOPEN \
-
+LOCAL_CFLAGS += -DUSE_X86_ASM -DHAVE_DLOPEN
+else ifeq ($(TARGET_2ND_ARCH),x86)
+LOCAL_CFLAGS_x86 += -DUSE_X86_ASM -DHAVE_DLOPEN
+LOCAL_CFLAGS_x86_64 += -DUSE_X86_64_ASM -DHAVE_DLOPEN
+LOCAL_ASFLAGS_x86_64 := -DUSE_X86_64_ASM
 endif
 endif
 
diff --git a/Android.mk b/Android.mk
index b19419b..cd85937 100644
--- a/Android.mk
+++ b/Android.mk
@@ -62,7 +62,7 @@ MESA_GPU_DRIVERS := $(filter-out $(invalid_drivers), $(MESA_GPU_DRIVERS))
 endif
 
 # host and target must be the same arch to generate matypes.h
-ifeq ($(TARGET_ARCH),$(HOST_ARCH))
+ifneq ($(filter $(TARGET_ARCH) $(TARGET_2ND_ARCH),x86),)
 MESA_ENABLE_ASM := true
 else
 MESA_ENABLE_ASM := false
diff --git a/src/mapi/Android.mk b/src/mapi/Android.mk
index 4445218..c909d68 100644
--- a/src/mapi/Android.mk
+++ b/src/mapi/Android.mk
@@ -47,6 +47,8 @@ LOCAL_CFLAGS := \
 	-DMAPI_MODE_GLAPI \
 	-DMAPI_ABI_HEADER=\"$(abi_header)\"
 
+LOCAL_LDFLAGS := -Wl,--no-warn-shared-textrel
+
 LOCAL_C_INCLUDES := \
 	$(MESA_TOP)/src/mapi
 
diff --git a/src/mesa/Android.gen.mk b/src/mesa/Android.gen.mk
index 27656cd..fb4a616 100644
--- a/src/mesa/Android.gen.mk
+++ b/src/mesa/Android.gen.mk
@@ -45,11 +45,9 @@ LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
 LOCAL_C_INCLUDES += $(intermediates)/main
 
 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
-ifeq ($(TARGET_ARCH),x86)
 sources += x86/matypes.h
 LOCAL_C_INCLUDES += $(intermediates)/x86
 endif
-endif
 
 sources += main/git_sha1.h
 
diff --git a/src/mesa/Android.libmesa_dricore.mk b/src/mesa/Android.libmesa_dricore.mk
index 7758d54..0636b2f 100644
--- a/src/mesa/Android.libmesa_dricore.mk
+++ b/src/mesa/Android.libmesa_dricore.mk
@@ -44,6 +44,9 @@ LOCAL_SRC_FILES := \
 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
 ifeq ($(TARGET_ARCH),x86)
 	LOCAL_SRC_FILES += $(X86_FILES)
+else ifeq ($(TARGET_2ND_ARCH),x86)
+	LOCAL_SRC_FILES_x86 := $(X86_FILES)
+	LOCAL_SRC_FILES_x86_64 := $(X86_64_FILES)
 endif # x86
 endif # MESA_ENABLE_ASM
 
diff --git a/src/mesa/Android.libmesa_st_mesa.mk b/src/mesa/Android.libmesa_st_mesa.mk
index b4b7fd9..cec59a9 100644
--- a/src/mesa/Android.libmesa_st_mesa.mk
+++ b/src/mesa/Android.libmesa_st_mesa.mk
@@ -43,6 +43,9 @@ LOCAL_SRC_FILES := \
 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
 ifeq ($(TARGET_ARCH),x86)
 	LOCAL_SRC_FILES += $(X86_FILES)
+else ifeq ($(TARGET_2ND_ARCH),x86)
+	LOCAL_SRC_FILES_x86 := $(X86_FILES)
+	LOCAL_SRC_FILES_x86_64 := $(X86_64_FILES)
 endif # x86
 endif # MESA_ENABLE_ASM
 
diff --git a/src/mesa/Android.mesa_gen_matypes.mk b/src/mesa/Android.mesa_gen_matypes.mk
index 6e301f9..296191e 100644
--- a/src/mesa/Android.mesa_gen_matypes.mk
+++ b/src/mesa/Android.mesa_gen_matypes.mk
@@ -25,7 +25,6 @@
 # ---------------------------------------------------------------------
 
 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
-ifeq ($(TARGET_ARCH),x86)
 
 LOCAL_PATH := $(call my-dir)
 
@@ -33,6 +32,7 @@ include $(CLEAR_VARS)
 
 LOCAL_MODULE := mesa_gen_matypes
 LOCAL_IS_HOST_MODULE := true
+LOCAL_MULTILIB := 32
 
 LOCAL_C_INCLUDES := \
 	$(MESA_TOP)/src/mapi \
@@ -44,5 +44,4 @@ LOCAL_SRC_FILES := \
 include $(MESA_COMMON_MK)
 include $(BUILD_HOST_EXECUTABLE)
 
-endif # x86
 endif # MESA_ENABLE_ASM
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 29f2499..627fbb8 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -179,7 +179,7 @@ static inline int IROUND_POS(float f)
  */
 static inline int F_TO_I(float f)
 {
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+#if defined(USE_X86_ASM) && (defined(__GNUC__) || defined(ANDROID)) && defined(__i386__)
    int r;
    __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
    return r;
@@ -201,7 +201,7 @@ static inline int F_TO_I(float f)
 /** Return (as an integer) floor of float */
 static inline int IFLOOR(float f)
 {
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+#if defined(USE_X86_ASM) && (defined(__GNUC__) || defined(ANDROID)) && defined(__i386__)
    /*
     * IEEE floor for computers that round to nearest or even.
     * 'f' must be between -4194304 and 4194303.
@@ -233,7 +233,7 @@ static inline int IFLOOR(float f)
 /** Return (as an integer) ceiling of float */
 static inline int ICEIL(float f)
 {
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+#if defined(USE_X86_ASM) && (defined(__GNUC__) || defined(ANDROID)) && defined(__i386__)
    /*
     * IEEE ceil for computers that round to nearest or even.
     * 'f' must be between -4194304 and 4194303.
-- 
1.9.1



More information about the mesa-dev mailing list