Skip to content

Commit 1cef371

Browse files
author
[email protected] 3D7058897 Wen-Yu (Vincent) Chang
committed
Adding support for s390x
1 parent 0ecdb4d commit 1cef371

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ $(SNAPPY_GIT_UNPACKED):
4747
git clone $(GIT_REPO_URL) $(SNAPPY_SRC_DIR)
4848
git --git-dir=$(SNAPPY_SRC_DIR)/.git --work-tree=$(SNAPPY_SRC_DIR) checkout -b local/snappy-$(GIT_SNAPPY_BRANCH) $(GIT_SNAPPY_BRANCH)
4949
touch $@
50-
cd $(SNAPPY_SRC_DIR) && ./configure
50+
cd $(SNAPPY_SRC_DIR) && ./cutogen.sh && ./onfigure
5151

5252
jni-header: $(SRC)/org/xerial/snappy/SnappyNative.h
5353

Makefile.common

+36-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ endif
4242

4343
# os=Default is meant to be generic unix/linux
4444

45-
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armhf Linux-ppc64 Mac-x86 Mac-x86_64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc64
45+
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armhf Linux-ppc Linux-ppc64 Linux-s390 Linux-s390x Mac-x86 Mac-x86_64 FreeBSD-x86_64 Windows-x86 Windows-x86_64 SunOS-x86 SunOS-sparc SunOS-x86_64 AIX-ppc64
4646
os_arch := $(OS_NAME)-$(OS_ARCH)
4747
IBM_JDK_7 := $(findstring IBM, $(shell $(JAVA) -version 2>&1 | grep IBM | grep "JRE 1.7"))
4848

@@ -94,12 +94,23 @@ Linux-x86_64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
9494
Linux-x86_64_LIBNAME := libsnappyjava.so
9595
Linux-x86_64_SNAPPY_FLAGS :=
9696

97+
Linux-ppc_CXX := g++
98+
Linux-ppc_STRIP := strip
99+
ifeq ($(IBM_JDK_7),)
100+
Linux-ppc_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m32
101+
else
102+
Linux-ppc_CXXFLAGS := -DHAVE_CONFIG_H -include lib/inc_linux/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC -m32
103+
endif
104+
Linux-ppc_LINKFLAGS := -shared -static-libgcc -static-libstdc++
105+
Linux-ppc_LIBNAME := libsnappyjava.so
106+
Linux-ppc_SNAPPY_FLAGS :=
107+
97108
Linux-ppc64_CXX := g++
98109
Linux-ppc64_STRIP := strip
99110
ifeq ($(IBM_JDK_7),)
100111
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
101112
else
102-
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC
113+
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -include $(IBM_JDK_LIB)/jni_md.h -include $(IBM_JDK_LIB)/jniport.h -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -O2 -fPIC -m64
103114
endif
104115
Linux-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
105116
Linux-ppc64_LIBNAME := libsnappyjava.so
@@ -116,6 +127,29 @@ endif
116127
AIX-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++ -lcrypt
117128
AIX-ppc64_SNAPPY_FLAGS :=
118129

130+
Linux-s390_CXX := g++
131+
Linux-s390_STRIP := strip
132+
ifeq ($(IBM_JDK_7),)
133+
Linux-s390_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m31
134+
else
135+
Linux-s390_CXXFLAGS := -DHAVE_CONFIG_H -I$(JAVA_HOME)/include/linux -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -m31
136+
endif
137+
Linux-s390_LINKFLAGS := -shared -static-libgcc -static-libstdc++
138+
Linux-s390_LIBNAME := libsnappyjava.so
139+
Linux-s390_SNAPPY_FLAGS :=
140+
141+
Linux-s390x_CXX := g++
142+
Linux-s390x_STRIP := strip
143+
ifeq ($(IBM_JDK_7),)
144+
Linux-s390x_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
145+
else
146+
Linux-s390x_CXXFLAGS := -DHAVE_CONFIG_H -I$(JAVA_HOME)/include/linux -Ilib/inc_ibm -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -m64
147+
endif
148+
#Linux-s390x_LINKFLAGS := -shared -static-libgcc -static-libstdc++
149+
Linux-s390x_LINKFLAGS := -shared -static-libgcc
150+
Linux-s390x_LIBNAME := libsnappyjava.so
151+
Linux-s390x_SNAPPY_FLAGS :=
152+
119153
SunOS-x86_CXX := g++
120154
SunOS-x86_STRIP := strip
121155
SunOS-x86_CXXFLAGS := -include lib/inc_linux/jni_md.h -I$(JAVA_HOME)/include -O2 -fPIC -fvisibility=hidden

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ When building on Solaris use
107107

108108
A file `target/snappy-java-$(version).jar` is the product additionally containing the native library built for your platform.
109109

110-
## Building linux x86_64 binary
110+
## Building linux x86\_64 binary
111111

112112
snappy-java tries to static link libstdc++ to increase the availability for various Linux versions. However, standard distributions of 64-bit Linux OS rarely provide libstdc++ compiled with `-fPIC` option. I currently uses custom g++, compiled as follows:
113113

@@ -127,6 +127,14 @@ $ make install
127127

128128
This g++ build enables static linking of libstdc++. For more infomation on building GCC, see GCC's home page.
129129

130+
## Building Linux s390/s390x binaries
131+
132+
Older snapshots of snappy contain a buggy config.h.in that does not work properly on some big-endian platforms like Linux on IBM z (s390/s390x). Building snappy-java on s390/s390x requires fetching the snappy source from GitHub, and processing the source with autoconf to obtain a usable config.h. On a RHEL s390x system, these steps produced a working 64-bit snappy-java build (the process should be similar for other distributions):
133+
134+
$ sudo yum install java-1.7.1-ibm-devel libstdc++-static-devel
135+
$ export JAVA_HOME=/usr/lib/jvm/java-1.7.1-ibm-1.7.1.2.10-1jpp.3.el7_0.s390x
136+
$ make USE_GIT=1 GIT_REPO_URL=https://github.com/google/snappy.git GIT_SNAPPY_BRANCH=master IBM_JDK_7=1
137+
130138
## Cross-compiling for other platforms
131139
The Makefile contains rules for cross-compiling the native library for other platforms so that the snappy-java JAR can support multiple platforms. For example, to build the native libraries for x86 Linux, x86 and x86-64 Windows, and soft- and hard-float ARM:
132140

build.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ OsgiKeys.additionalHeaders := Map(
9595
"org/xerial/snappy/native/Linux/arm/libsnappyjava.so;osname=linux;processor=arm",
9696
"org/xerial/snappy/native/Linux/ppc64/libsnappyjava.so;osname=linux;processor=ppc64",
9797
"org/xerial/snappy/native/Linux/ppc64le/libsnappyjava.so;osname=linux;processor=ppc64le",
98+
"org/xerial/snappy/native/Linux/s390x/libsnappyjava.so;osname=linux;processor=s390x",
9899
"org/xerial/snappy/native/AIX/ppc64/libsnappyjava.a;osname=aix;processor=ppc64",
99100
"org/xerial/snappy/native/SunOS/x86/libsnappyjava.so;osname=sunos;processor=x86",
100101
"org/xerial/snappy/native/SunOS/x86_64/libsnappyjava.so;osname=sunos;processor=x86-64",

src/main/java/org/xerial/snappy/OSInfo.java

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ public class OSInfo
4444
public static final String IA64 = "ia64";
4545
public static final String PPC = "ppc";
4646
public static final String PPC64 = "ppc64";
47+
public static final String IBMZ = "s390";
48+
public static final String IBMZ_64 = "s390x";
4749

4850
static {
4951
// x86 mappings
@@ -81,6 +83,12 @@ public class OSInfo
8183
archMapping.put("powerpc64", PPC64);
8284
archMapping.put("power_pc64", PPC64);
8385
archMapping.put("power_rs64", PPC64);
86+
87+
// IBM z mappings
88+
archMapping.put(IBMZ, IBMZ);
89+
90+
// IBM z 64-bit mappings
91+
archMapping.put(IBMZ_64, IBMZ_64);
8492
}
8593

8694

Binary file not shown.

0 commit comments

Comments
 (0)