From 3ccbf7ef088ae5ed0540a1051c11dcaea0c9263e Mon Sep 17 00:00:00 2001
From: Ken Wakasa <kwakasa@google.com>
Date: Fri, 4 Apr 2014 19:55:59 +0900
Subject: [PATCH] 32-bit dicttool

As we can't easily turn on -m64 for only one module, the JNI library for
a host tool should be 32-bit, at least for now.

Change-Id: I1f001ccca1ad968a2241c0494bb70391fb11a59f
---
 tools/dicttool/NativeLib.mk      |  9 +--------
 tools/dicttool/etc/dicttool_aosp | 11 ++++++++++-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/tools/dicttool/NativeLib.mk b/tools/dicttool/NativeLib.mk
index 0d3507be3b..30444493ca 100644
--- a/tools/dicttool/NativeLib.mk
+++ b/tools/dicttool/NativeLib.mk
@@ -29,13 +29,7 @@ ifeq ($(FLAG_DBG), true)
     LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables -fno-inline
 endif #FLAG_DBG
 
-ifneq ($(strip $(HOST_JDK_IS_64BIT_VERSION)),)
-LOCAL_CFLAGS += -m64
-LOCAL_LDFLAGS += -m64
-endif #HOST_JDK_IS_64BIT_VERSION
-
-LOCAL_CFLAGS += -DHOST_TOOL -fPIC -Wno-deprecated
-LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
+LOCAL_CFLAGS += -DHOST_TOOL -fPIC -Wno-deprecated -Wno-unused-parameter -Wno-unused-function
 
 LOCAL_CLANG := true
 # For C++11
@@ -44,7 +38,6 @@ LOCAL_CFLAGS += -std=c++11
 LATINIME_NATIVE_JNI_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni
 LATINIME_NATIVE_SRC_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni/src
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LATINIME_NATIVE_SRC_DIR)
-# Used in jni_common.cpp to avoid registering useless methods.
 
 include $(LOCAL_PATH)/$(LATINIME_NATIVE_JNI_DIR)/NativeFileList.mk
 
diff --git a/tools/dicttool/etc/dicttool_aosp b/tools/dicttool/etc/dicttool_aosp
index 65a1c3a1c0..09d65c691f 100755
--- a/tools/dicttool/etc/dicttool_aosp
+++ b/tools/dicttool/etc/dicttool_aosp
@@ -68,5 +68,14 @@ else
     libpath="$frameworkdir/$lib"
 fi
 
+# Check if the host Java executable supports a 32-bit JVM. It needs to do because the JNI
+# library is 32-bit.
+${DICTTOOL_JAVA-java} -d32 -version > /dev/null 2>&1
+if [[ $? != 0 ]] ; then
+    echo Please specify a Java executable that supports a 32-bit JVM as DICTTOOL_JAVA.
+    exit 1
+fi
+
 # might need more memory, e.g. -Xmx128M
-exec java -ea -classpath "$libpath":"$jarpath" -Djava.library.path="$libdir" "$classname" "$@"
+exec ${DICTTOOL_JAVA-java} -d32 -ea -classpath "$libpath":"$jarpath" \
+    -Djava.library.path="$libdir" "$classname" "$@"
-- 
GitLab