Skip to content

Commit

Permalink
Build on loongarch64
Browse files Browse the repository at this point in the history
Signed-off-by: Leslie Zhai <[email protected]>
  • Loading branch information
xiangzhai authored and Leslie Zhai committed Oct 17, 2023
1 parent d7356d5 commit d057948
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ native: jni-header snappy-header $(NATIVE_DLL)
native-nocmake: jni-header $(NATIVE_DLL)
snappy: native $(TARGET)/$(snappy-jar-version).jar

native-all: native native-arm clean-docker mac64 win32 win64 linux32 linux64 linux-ppc64le linux-riscv64 linux-s390x
native-all: native native-arm clean-docker mac64 win32 win64 linux32 linux64 linux-ppc64le linux-riscv64 linux-s390x linux-loongarch64

ifdef CI
# Clean docker images within CI to avoid no space left error
Expand Down Expand Up @@ -240,6 +240,9 @@ linux-s390x: jni-header
windows-aarch64: jni-header
./docker/dockcross-windows-arm64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/aarch64-w64-mingw32-cross/bin/aarch64-w64-mingw32- OS_NAME=Windows OS_ARCH=aarch64'

linux-loongarch64: jni-header
./docker/dockcross-loongarch64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=/usr/xcc/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu- OS_NAME=Linux OS_ARCH=loongarch64'

javadoc:
$(SBT) doc

Expand Down
16 changes: 15 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endif
# os=Default is meant to be generic unix/linux

# To support new CPU architecture, add a new target name here
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-android-aarch64 Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 Windows-aarch64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc AIX-ppc64 Linux-riscv Linux-riscv64
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-android-aarch64 Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 Mac-aarch64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 Windows-aarch64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc AIX-ppc64 Linux-riscv Linux-riscv64 Linux-loongarch Linux-loongarch64
os_arch := $(OS_NAME)-$(OS_ARCH)
IBM_JDK_7 := $(findstring IBM, $(shell $(JAVA) -version 2>&1 | grep IBM | grep "JRE 1.7"))

Expand Down Expand Up @@ -310,6 +310,20 @@ Windows-aarch64_CXXFLAGS := -Ilib/inc_mac -I$(JAVA_HOME)/include -O2 -fPIC -mar
Windows-aarch64_LINKFLAGS := -Wl,--kill-at -shared -static
Windows-aarch64_LIBNAME := snappyjava.dll

Linux-loongarch_CXX := $(CROSS_PREFIX)g++
Linux-loongarch_STRIP := $(CROSS_PREFIX)strip
Linux-loongarch_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-loongarch_LINKFLAGS := -shared
Linux-loongarch_LIBNAME := libsnappyjava.so
Linux-loongarch_SNAPPY_FLAGS:=

Linux-loongarch64_CXX := $(CROSS_PREFIX)g++
Linux-loongarch64_STRIP := $(CROSS_PREFIX)strip
Linux-loongarch64_CXXFLAGS := -Ilib/inc_linux -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden -std=c++11
Linux-loongarch64_LINKFLAGS := -shared
Linux-loongarch64_LIBNAME := libsnappyjava.so
Linux-loongarch64_SNAPPY_FLAGS:=


CXX := $($(os_arch)_CXX)
STRIP := $($(os_arch)_STRIP)
Expand Down
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ OsgiKeys.additionalHeaders := Map(
"org/xerial/snappy/native/Linux/armv7/libsnappyjava.so;osname=linux;processor=arm_le",
"org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64le",
"org/xerial/snappy/native/Linux/s390x/libsnappyjava.so;osname=linux;processor=s390x",
"org/xerial/snappy/native/Linux/loongarch64/libsnappyjava.so;osname=linux;processor=loongarch64",
"org/xerial/snappy/native/AIX/ppc/libsnappyjava.a;osname=aix;processor=ppc",
"org/xerial/snappy/native/AIX/ppc64/libsnappyjava.a;osname=aix;processor=ppc64",
"org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86",
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/xerial/snappy/OSInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class OSInfo {
public static final String IBMZ_64 = "s390x";
public static final String AARCH_64 = "aarch64";
public static final String RISCV_64 = "riscv64";
public static final String LOONGARCH_64 = "loongarch64";

static {
// x86 mappings
Expand Down Expand Up @@ -97,6 +98,9 @@ public class OSInfo {

// RISC-V mappings
archMapping.put(RISCV_64, RISCV_64);

// LoongArch64 mappings
archMapping.put(LOONGARCH_64, LOONGARCH_64);
}

public static void main(String[] args) {
Expand Down
Binary file not shown.

0 comments on commit d057948

Please sign in to comment.