Skip to content

Commit

Permalink
Support rocksdbjava aarch64 build and test (#5258)
Browse files Browse the repository at this point in the history
Summary:
Verified with an Ampere Computing eMAG aarch64 system.
Pull Request resolved: #5258

Differential Revision: D15807309

Pulled By: maysamyabandeh

fbshipit-source-id: ab85d2fd3fe40e6094430ab0eba557b1e979510d
  • Loading branch information
cnqpzhang authored and adamretter committed Dec 20, 2019
1 parent a764ed0 commit c75cb1e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/linux
ifeq ($(PLATFORM), OS_SOLARIS)
ARCH := $(shell isainfo -b)
else ifeq ($(PLATFORM), OS_OPENBSD)
ifneq (,$(filter $(MACHINE), amd64 arm64 sparc64))
ifneq (,$(filter $(MACHINE), amd64 arm64 sparc64 aarch64))
ARCH := 64
else
ARCH := 32
Expand All @@ -1655,6 +1655,9 @@ ifeq (,$(findstring ppc,$(MACHINE)))
else
ROCKSDBJNILIB = librocksdbjni-linux-$(MACHINE).so
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_ALL = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar
ROCKSDB_JAVADOCS_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar
Expand Down
2 changes: 2 additions & 0 deletions build_tools/build_detect_platform
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ if test -z "$PORTABLE"; then
elif test -n "`echo $TARGET_ARCHITECTURE | grep ^arm`"; then
# TODO: Handle this with approprite options.
COMMON_FLAGS="$COMMON_FLAGS"
elif test -n "`echo $TARGET_ARCHITECTURE | grep ^aarch64`"; then
COMMON_FLAGS="$COMMON_FLAGS"
elif [ "$TARGET_OS" == "IOS" ]; then
COMMON_FLAGS="$COMMON_FLAGS"
elif [ "$TARGET_OS" != "AIX" ] && [ "$TARGET_OS" != "SunOS" ]; then
Expand Down
6 changes: 5 additions & 1 deletion java/src/main/java/org/rocksdb/util/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ public class Environment {
private static String OS = System.getProperty("os.name").toLowerCase();
private static String ARCH = System.getProperty("os.arch").toLowerCase();

public static boolean isAarch64() {
return ARCH.contains("aarch64");
}

public static boolean isPowerPC() {
return ARCH.contains("ppc");
}
Expand Down Expand Up @@ -59,7 +63,7 @@ public static String getSharedLibraryFileName(final String name) {
public static String getJniLibraryName(final String name) {
if (isUnix()) {
final String arch = is64Bit() ? "64" : "32";
if(isPowerPC()) {
if(isPowerPC() || isAarch64()) {
return String.format("%sjni-linux-%s", name, ARCH);
} else if(isS390x()) {
return String.format("%sjni-linux%s", name, ARCH);
Expand Down
18 changes: 18 additions & 0 deletions java/src/test/java/org/rocksdb/util/EnvironmentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ public void win64() {
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,
String osArch) {
setEnvironmentClassField(OS_FIELD_NAME, osName);
Expand Down

0 comments on commit c75cb1e

Please sign in to comment.