Support rocksdbjava aarch64 build and test (#5258)

Summary:
Verified with an Ampere Computing eMAG aarch64 system.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5258

Differential Revision: D15807309

Pulled By: maysamyabandeh

fbshipit-source-id: ab85d2fd3fe40e6094430ab0eba557b1e979510d
main
Patrick Zhang 6 years ago committed by Facebook Github Bot
parent 60f3ec2ca5
commit 5c76ba9dc4
  1. 5
      Makefile
  2. 2
      build_tools/build_detect_platform
  3. 6
      java/src/main/java/org/rocksdb/util/Environment.java
  4. 18
      java/src/test/java/org/rocksdb/util/EnvironmentTest.java

@ -1641,7 +1641,7 @@ JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/linux
ifeq ($(PLATFORM), OS_SOLARIS) ifeq ($(PLATFORM), OS_SOLARIS)
ARCH := $(shell isainfo -b) ARCH := $(shell isainfo -b)
else ifeq ($(PLATFORM), OS_OPENBSD) else ifeq ($(PLATFORM), OS_OPENBSD)
ifneq (,$(filter $(MACHINE), amd64 arm64 sparc64)) ifneq (,$(filter $(MACHINE), amd64 arm64 sparc64 aarch64))
ARCH := 64 ARCH := 64
else else
ARCH := 32 ARCH := 32
@ -1655,6 +1655,9 @@ ifeq (,$(findstring ppc,$(MACHINE)))
else else
ROCKSDBJNILIB = librocksdbjni-linux-$(MACHINE).so ROCKSDBJNILIB = librocksdbjni-linux-$(MACHINE).so
endif endif
ifneq (,$(findstring aarch64,$(MACHINE)))
ROCKSDBJNILIB = librocksdbjni-linux-$(MACHINE).so
endif
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux$(ARCH).jar ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux$(ARCH).jar
ROCKSDB_JAR_ALL = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar ROCKSDB_JAR_ALL = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar
ROCKSDB_JAVADOCS_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar ROCKSDB_JAVADOCS_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar

@ -540,6 +540,8 @@ if test -z "$PORTABLE"; then
elif test -n "`echo $TARGET_ARCHITECTURE | grep ^arm`"; then elif test -n "`echo $TARGET_ARCHITECTURE | grep ^arm`"; then
# TODO: Handle this with approprite options. # TODO: Handle this with approprite options.
COMMON_FLAGS="$COMMON_FLAGS" COMMON_FLAGS="$COMMON_FLAGS"
elif test -n "`echo $TARGET_ARCHITECTURE | grep ^aarch64`"; then
COMMON_FLAGS="$COMMON_FLAGS"
elif [ "$TARGET_OS" == "IOS" ]; then elif [ "$TARGET_OS" == "IOS" ]; then
COMMON_FLAGS="$COMMON_FLAGS" COMMON_FLAGS="$COMMON_FLAGS"
elif [ "$TARGET_OS" != "AIX" ] && [ "$TARGET_OS" != "SunOS" ]; then elif [ "$TARGET_OS" != "AIX" ] && [ "$TARGET_OS" != "SunOS" ]; then

@ -5,6 +5,10 @@ public class Environment {
private static String OS = System.getProperty("os.name").toLowerCase(); private static String OS = System.getProperty("os.name").toLowerCase();
private static String ARCH = System.getProperty("os.arch").toLowerCase(); private static String ARCH = System.getProperty("os.arch").toLowerCase();
public static boolean isAarch64() {
return ARCH.contains("aarch64");
}
public static boolean isPowerPC() { public static boolean isPowerPC() {
return ARCH.contains("ppc"); return ARCH.contains("ppc");
} }
@ -60,7 +64,7 @@ public class Environment {
public static String getJniLibraryName(final String name) { public static String getJniLibraryName(final String name) {
if (isUnix()) { if (isUnix()) {
final String arch = is64Bit() ? "64" : "32"; final String arch = is64Bit() ? "64" : "32";
if(isPowerPC()) { if(isPowerPC() || isAarch64()) {
return String.format("%sjni-linux-%s", name, ARCH); return String.format("%sjni-linux-%s", name, ARCH);
} else if(isS390x()) { } else if(isS390x()) {
return String.format("%sjni-linux%s", name, ARCH); return String.format("%sjni-linux%s", name, ARCH);

@ -130,6 +130,24 @@ public class EnvironmentTest {
isEqualTo("librocksdbjni.dll"); isEqualTo("librocksdbjni.dll");
} }
@Test
public void aarch64() {
setEnvironmentClassFields("Linux", "aarch64");
assertThat(Environment.isUnix()).isTrue();
assertThat(Environment.isAarch64()).isTrue();
assertThat(Environment.is64Bit()).isTrue();
assertThat(Environment.getJniLibraryExtension()).
isEqualTo(".so");
assertThat(Environment.getSharedLibraryName("rocksdb")).
isEqualTo("rocksdbjni");
assertThat(Environment.getJniLibraryName("rocksdb")).
isEqualTo("rocksdbjni-linux-aarch64");
assertThat(Environment.getJniLibraryFileName("rocksdb")).
isEqualTo("librocksdbjni-linux-aarch64.so");
assertThat(Environment.getSharedLibraryFileName("rocksdb")).
isEqualTo("librocksdbjni.so");
}
private void setEnvironmentClassFields(String osName, private void setEnvironmentClassFields(String osName,
String osArch) { String osArch) {
setEnvironmentClassField(OS_FIELD_NAME, osName); setEnvironmentClassField(OS_FIELD_NAME, osName);

Loading…
Cancel
Save