Skip to content

Commit 3497e73

Browse files
committed
xerial#168: Add ppc64 target
1 parent ee4d27b commit 3497e73

File tree

6 files changed

+286
-2
lines changed

6 files changed

+286
-2
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ snappy-jar-version:=snappy-java-$(shell perl -npe "s/version in ThisBuild\s+:=\s
135135
native: jni-header $(NATIVE_DLL)
136136
snappy: native $(TARGET)/$(snappy-jar-version).jar
137137

138-
native-all: win32 win64 mac64 native-arm linux32 linux64 linux-ppc64le linux-aarch64
138+
native-all: win32 win64 mac64 native-arm linux32 linux64 linux-ppc64 linux-ppc64le linux-aarch64
139139

140140
$(NATIVE_DLL): $(SNAPPY_SOURCE_CONFIGURED) $(SNAPPY_OUT)/$(LIBNAME)
141141
@mkdir -p $(@D)
@@ -193,6 +193,9 @@ linux-android-arm: jni-header
193193
linux-ppc64le: jni-header
194194
./docker/dockcross-ppc64le -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=powerpc64le-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64le'
195195

196+
linux-ppc64: jni-header
197+
./docker/dockcross-ppc64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=ppc64-linux-gnu- OS_NAME=Linux OS_ARCH=ppc64'
198+
196199
linux-aarch64: jni-header
197200
./docker/dockcross-aarch64 -a $(DOCKER_RUN_OPTS) bash -c 'make clean-native native CROSS_PREFIX=aarch64-linux-gnu- OS_NAME=Linux OS_ARCH=aarch64'
198201

Makefile.common

Lines changed: 12 additions & 1 deletion
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-armv6 Linux-armv7 Linux-android-arm Linux-aarch64 Linux-ppc Linux-ppc64le 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-ppc AIX-ppc64
45+
known_os_archs := Linux-x86 Linux-x86_64 Linux-arm Linux-armv6 Linux-armv7 Linux-android-arm Linux-aarch64 Linux-ppc Linux-ppc64 Linux-ppc64le 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-ppc 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

@@ -116,6 +116,17 @@ Linux-ppc64le_LINKFLAGS := -shared -static-libgcc -static-libstdc++
116116
Linux-ppc64le_LIBNAME := libsnappyjava.so
117117
Linux-ppc64le_SNAPPY_FLAGS :=
118118

119+
Linux-ppc64_CXX := g++
120+
Linux-ppc64_STRIP := strip
121+
ifeq ($(IBM_JDK_7),)
122+
Linux-ppc64_CXXFLAGS := -DHAVE_CONFIG_H -Ilib/inc_linux -I$(JAVA_HOME)/include -Ilib/inc_mac -O2 -fPIC -fvisibility=hidden -m64
123+
else
124+
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
125+
endif
126+
Linux-ppc64_LINKFLAGS := -shared -static-libgcc -static-libstdc++
127+
Linux-ppc64_LIBNAME := libsnappyjava.so
128+
Linux-ppc64_SNAPPY_FLAGS :=
129+
119130
AIX-ppc_CXX := g++
120131
AIX-ppc_STRIP := strip
121132
AIX-ppc_LIBNAME := libsnappyjava.a

docker/Dockerfile.linux-ppc64

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM dockcross/base:latest
2+
MAINTAINER Taro L. Saito "[email protected]"
3+
4+
# Add the cross compiler sources
5+
RUN echo "deb http://emdebian.org/tools/debian/ jessie main" >> /etc/apt/sources.list && \
6+
dpkg --add-architecture powerpc && \
7+
curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add -
8+
9+
RUN apt-get update && apt-get install -y \
10+
crossbuild-essential-powerpc \
11+
gfortran-powerpc-linux-gnu \
12+
libbz2-dev:powerpc \
13+
libexpat1-dev:powerpc \
14+
ncurses-dev:powerpc \
15+
libssl-dev:powerpc
16+
17+
WORKDIR /usr/src
18+
19+
RUN apt-get update && \
20+
apt-get install -y libglib2.0-dev zlib1g-dev libpixman-1-dev && \
21+
curl -L http://wiki.qemu-project.org/download/qemu-2.6.0.tar.bz2 | tar xj && \
22+
cd qemu-2.6.0 && \
23+
./configure --target-list=ppc64-linux-user --prefix=/usr && \
24+
make -j$(nproc) && \
25+
make install && \
26+
cd .. && rm -rf qemu-2.6.0
27+
28+
ENV CROSS_TRIPLE ppc64-linux-gnu
29+
ENV CROSS_ROOT /usr/${CROSS_TRIPLE}
30+
ENV AS=/usr/bin/${CROSS_TRIPLE}-as \
31+
AR=/usr/bin/${CROSS_TRIPLE}-ar \
32+
CC=/usr/bin/${CROSS_TRIPLE}-gcc \
33+
CPP=/usr/bin/${CROSS_TRIPLE}-cpp \
34+
CXX=/usr/bin/${CROSS_TRIPLE}-g++ \
35+
LD=/usr/bin/${CROSS_TRIPLE}-ld
36+
37+
ENV DEFAULT_DOCKCROSS_IMAGE dockcross/linux-ppc64
38+
WORKDIR /work
39+
40+
# Note: Toolchain file support is currently in debian Experimental according to:
41+
# https://wiki.debian.org/CrossToolchains#In_jessie_.28Debian_8.29
42+
# We can switch to that when it becomes stable.
43+
COPY Toolchain-ppc64.cmake /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake
44+
ENV CMAKE_TOOLCHAIN_FILE /usr/lib/${CROSS_TRIPLE}/Toolchain.cmake
45+
46+
# Build-time metadata as defined at http://label-schema.org
47+
ARG BUILD_DATE
48+
ARG IMAGE
49+
ARG VCS_REF
50+
ARG VCS_URL
51+
LABEL org.label-schema.build-date=$BUILD_DATE \
52+
org.label-schema.name=$IMAGE \
53+
org.label-schema.vcs-ref=$VCS_REF \
54+
org.label-schema.vcs-url=$VCS_URL \
55+
org.label-schema.schema-version="1.0"

docker/Toolchain-ppc64.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(CMAKE_SYSTEM_NAME Linux)
2+
set(CMAKE_SYSTEM_VERSION 1)
3+
set(CMAKE_SYSTEM_PROCESSOR ppc64)
4+
5+
set(cross_triple "ppc64-linux-gnu")
6+
7+
set(CMAKE_C_COMPILER /usr/bin/${cross_triple}-cc)
8+
set(CMAKE_CXX_COMPILER /usr/bin/${cross_triple}-c++)
9+
set(CMAKE_Fortran_COMPILER /usr/bin/${cross_triple}-gfortran)
10+
11+
# Discard path returned by pkg-config and associated with HINTS in module
12+
# like FindOpenSSL.
13+
set(CMAKE_IGNORE_PATH /usr/lib/x86_64-linux-gnu/ /usr/lib/x86_64-linux-gnu/lib/)
14+
15+
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-ppc64)

docker/dockcross-ppc64

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
#!/bin/bash
2+
3+
DEFAULT_DOCKCROSS_IMAGE=xerial/linux-ppc64
4+
5+
#------------------------------------------------------------------------------
6+
# Helpers
7+
#
8+
err() {
9+
echo -e >&2 ERROR: $@\\n
10+
}
11+
12+
die() {
13+
err $@
14+
exit 1
15+
}
16+
17+
has() {
18+
# eg. has command update
19+
local kind=$1
20+
local name=$2
21+
22+
type -t $kind:$name | grep -q function
23+
}
24+
25+
#------------------------------------------------------------------------------
26+
# Command handlers
27+
#
28+
command:update-image() {
29+
docker pull $FINAL_IMAGE
30+
}
31+
32+
help:update-image() {
33+
echo Pull the latest $FINAL_IMAGE .
34+
}
35+
36+
command:update-script() {
37+
if cmp -s <( docker run $FINAL_IMAGE ) $0; then
38+
echo $0 is up to date
39+
else
40+
echo -n Updating $0 '... '
41+
docker run $FINAL_IMAGE > $0 && echo ok
42+
fi
43+
}
44+
45+
help:update-image() {
46+
echo Update $0 from $FINAL_IMAGE .
47+
}
48+
49+
command:update() {
50+
command:update-image
51+
command:update-script
52+
}
53+
54+
help:update() {
55+
echo Pull the latest $FINAL_IMAGE, and then update $0 from that.
56+
}
57+
58+
command:help() {
59+
if [[ $# != 0 ]]; then
60+
if ! has command $1; then
61+
err \"$1\" is not an dockcross command
62+
command:help
63+
elif ! has help $1; then
64+
err No help found for \"$1\"
65+
else
66+
help:$1
67+
fi
68+
else
69+
cat >&2 <<ENDHELP
70+
Usage: dockcross [options] [--] command [args]
71+
72+
By default, run the given *command* in an dockcross Docker container.
73+
74+
The *options* can be one of:
75+
76+
--args|-a Extra args to the *docker run* command
77+
--image|-i Docker cross-compiler image to use
78+
--config|-c Bash script to source before running this script
79+
80+
81+
Additionally, there are special update commands:
82+
83+
update-image
84+
update-script
85+
update
86+
87+
For update command help use: $0 help <command>
88+
ENDHELP
89+
exit 1
90+
fi
91+
}
92+
93+
#------------------------------------------------------------------------------
94+
# Option processing
95+
#
96+
special_update_command=''
97+
while [[ $# != 0 ]]; do
98+
case $1 in
99+
100+
--)
101+
break
102+
;;
103+
104+
--args|-a)
105+
ARG_ARGS="$2"
106+
shift 2
107+
;;
108+
109+
--config|-c)
110+
ARG_CONFIG="$2"
111+
shift 2
112+
;;
113+
114+
--image|-i)
115+
ARG_IMAGE="$2"
116+
shift 2
117+
;;
118+
update|update-image|update-script)
119+
special_update_command=$1
120+
break
121+
;;
122+
-*)
123+
err Unknown option \"$1\"
124+
command:help
125+
exit
126+
;;
127+
128+
*)
129+
break
130+
;;
131+
132+
esac
133+
done
134+
135+
# The precedence for options is:
136+
# 1. command-line arguments
137+
# 2. environment variables
138+
# 3. defaults
139+
140+
# Source the config file if it exists
141+
DEFAULT_DOCKCROSS_CONFIG=~/.dockcross
142+
FINAL_CONFIG=${ARG_CONFIG-${DOCKCROSS_CONFIG-$DEFAULT_DOCKCROSS_CONFIG}}
143+
144+
[[ -f "$FINAL_CONFIG" ]] && source "$FINAL_CONFIG"
145+
146+
# Set the docker image
147+
FINAL_IMAGE=${ARG_IMAGE-${DOCKCROSS_IMAGE-$DEFAULT_DOCKCROSS_IMAGE}}
148+
149+
# Handle special update command
150+
if [ "$special_update_command" != "" ]; then
151+
case $special_update_command in
152+
153+
update)
154+
command:update
155+
exit $?
156+
;;
157+
158+
update-image)
159+
command:update-image
160+
exit $?
161+
;;
162+
163+
update-script)
164+
command:update-script
165+
exit $?
166+
;;
167+
168+
esac
169+
fi
170+
171+
# Set the docker run extra args (if any)
172+
FINAL_ARGS=${ARG_ARGS-${DOCKCROSS_ARGS}}
173+
174+
# If we are not running via boot2docker
175+
if [ -z $DOCKER_HOST ]; then
176+
USER_IDS="-e BUILDER_UID=$( id -u ) -e BUILDER_GID=$( id -g ) -e BUILDER_USER=$( id -un ) -e BUILDER_GROUP=$( id -gn )"
177+
fi
178+
179+
#------------------------------------------------------------------------------
180+
# Now, finally, run the command in a container
181+
#
182+
docker run --rm \
183+
-v $PWD:/work \
184+
$USER_IDS \
185+
$FINAL_ARGS \
186+
$FINAL_IMAGE "$@"
187+
188+
################################################################################
189+
#
190+
# This image is not intended to be run manually.
191+
#
192+
# To create a dockcross helper script for the
193+
# dockcross/linux-armv7 image, run:
194+
#
195+
# docker run --rm dockcross/linux-armv7 > dockcross-linux-armv7
196+
# chmod +x dockcross-linux-armv7
197+
#
198+
# You may then wish to move the dockcross script to your PATH.
199+
#
200+
################################################################################
Binary file not shown.

0 commit comments

Comments
 (0)