mirror of https://github.com/grpc/grpc-java.git
Add support for cross-compiling for s390x platform (#9455)
* Added s390x platform support * Adapt to existing platform naming scheme * Updated s390_64 library whitelist * Use g++ compiler version 8.x for s390x * Introduced dedicated Docker container for building s390x artifacts Minor fix --------- Signed-off-by: Dirk Haubenreisser <haubenr@de.ibm.com> Co-authored-by: Eric Anderson <ejona@google.com>
This commit is contained in:
parent
39c9ebf180
commit
99cbdd5d69
|
|
@ -2,4 +2,6 @@
|
|||
set -eu -o pipefail
|
||||
|
||||
readonly buildscripts_dir="$(dirname "$(readlink -f "$0")")"
|
||||
docker build -t grpc-java-artifacts "$buildscripts_dir"/grpc-java-artifacts
|
||||
docker build -t grpc-java-artifacts-x86 "$buildscripts_dir"/grpc-java-artifacts
|
||||
docker build -t grpc-java-artifacts-multiarch -f "$buildscripts_dir"/grpc-java-artifacts/Dockerfile.multiarch.base "$buildscripts_dir"/grpc-java-artifacts
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
set -exu -o pipefail
|
||||
|
||||
# first we need to install the prerequisites required for s390x cross compilation
|
||||
apt-get update && apt-get install -y g++-s390x-linux-gnu
|
||||
|
||||
# now kick off the build for the mvn artifacts for s390x
|
||||
# mvn artifacts are stored in grpc-java/mvn-artifacts/
|
||||
SKIP_TESTS=true ARCH=s390_64 "$(dirname $0)"/kokoro/unix.sh
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
FROM ubuntu:22.04
|
||||
|
||||
# make sure apt-get works in unattended mode
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# install the OS-level prerequisites for building protobuf and running the gradle build
|
||||
RUN apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y --no-install-recommends ca-certificates build-essential wget curl openjdk-8-jdk && \
|
||||
apt-get autoclean -y && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
|
||||
|
||||
|
|
@ -11,7 +11,7 @@ readonly GRPC_JAVA_DIR="$(cd "$(dirname "$0")"/../.. && pwd)"
|
|||
trap spongify_logs EXIT
|
||||
|
||||
"$GRPC_JAVA_DIR"/buildscripts/build_docker.sh
|
||||
"$GRPC_JAVA_DIR"/buildscripts/run_in_docker.sh /grpc-java/buildscripts/build_artifacts_in_docker.sh
|
||||
"$GRPC_JAVA_DIR"/buildscripts/run_in_docker.sh grpc-java-artifacts-x86 /grpc-java/buildscripts/build_artifacts_in_docker.sh
|
||||
|
||||
# grpc-android, grpc-cronet and grpc-binder require the Android SDK, so build outside of Docker and
|
||||
# use --include-build for its grpc-core dependency
|
||||
|
|
@ -59,3 +59,9 @@ SKIP_TESTS=true ARCH=aarch_64 "$GRPC_JAVA_DIR"/buildscripts/kokoro/unix.sh
|
|||
# for ppc64le platform
|
||||
sudo apt-get install -y g++-powerpc64le-linux-gnu
|
||||
SKIP_TESTS=true ARCH=ppcle_64 "$GRPC_JAVA_DIR"/buildscripts/kokoro/unix.sh
|
||||
|
||||
# for s390x platform
|
||||
# building these artifacts inside a Docker container as we have specific requirements
|
||||
# for GCC (version 11.x needed) which in turn requires Ubuntu 22.04 LTS
|
||||
"$GRPC_JAVA_DIR"/buildscripts/run_in_docker.sh grpc-java-artifacts-multiarch /grpc-java/buildscripts/build_s390x_artifacts_in_docker.sh
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
# ARCH=aarch_64 ./buildscripts/kokoro/unix.sh
|
||||
# For ppc64le arch:
|
||||
# ARCH=ppcle_64 ./buildscripts/kokoro/unix.sh
|
||||
# For s390x arch:
|
||||
# ARCH=s390_64 ./buildscripts/kokoro/unix.sh
|
||||
|
||||
# This script assumes `set -e`. Removing it may lead to undefined behavior.
|
||||
set -exu -o pipefail
|
||||
|
|
@ -80,7 +82,7 @@ fi
|
|||
LOCAL_MVN_TEMP=$(mktemp -d)
|
||||
# Note that this disables parallel=true from GRADLE_FLAGS
|
||||
if [[ -z "${ALL_ARTIFACTS:-}" ]]; then
|
||||
if [[ "$ARCH" = "aarch_64" || "$ARCH" = "ppcle_64" ]]; then
|
||||
if [[ "$ARCH" = "aarch_64" || "$ARCH" = "ppcle_64" || "$ARCH" = "s390_64" ]]; then
|
||||
GRADLE_FLAGS+=" -x grpc-compiler:generateTestProto -x grpc-compiler:generateTestLiteProto"
|
||||
GRADLE_FLAGS+=" -x grpc-compiler:testGolden -x grpc-compiler:testLiteGolden"
|
||||
GRADLE_FLAGS+=" -x grpc-compiler:testDeprecatedGolden -x grpc-compiler:testDeprecatedLiteGolden"
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ LOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/
|
|||
# for linux ppc64le platform
|
||||
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-ppcle_64.exe' | wc -l)" != '0' ]]
|
||||
|
||||
# for linux s390x platform
|
||||
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-s390_64.exe' | wc -l)" != '0' ]]
|
||||
|
||||
# from macos job:
|
||||
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-osx-x86_64.exe' | wc -l)" != '0' ]]
|
||||
# copy all x86 artifacts to aarch until native artifacts are built
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ else
|
|||
./configure --disable-shared --host=aarch64-linux-gnu --prefix="$INSTALL_DIR"
|
||||
elif [[ "$ARCH" == ppc* ]]; then
|
||||
./configure --disable-shared --host=powerpc64le-linux-gnu --prefix="$INSTALL_DIR"
|
||||
elif [[ "$ARCH" == s390* ]]; then
|
||||
./configure --disable-shared --host=s390x-linux-gnu --prefix="$INSTALL_DIR"
|
||||
elif [[ "$ARCH" == loongarch* ]]; then
|
||||
./configure --disable-shared --host=loongarch64-unknown-linux-gnu --prefix="$INSTALL_DIR"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ quote() {
|
|||
done
|
||||
}
|
||||
|
||||
readonly docker_image=$1; shift
|
||||
|
||||
readonly grpc_java_dir="$(dirname "$(readlink -f "$0")")/.."
|
||||
if [[ -t 0 ]]; then
|
||||
DOCKER_ARGS="-it"
|
||||
|
|
@ -21,5 +23,5 @@ fi
|
|||
# the original exit code. $DOCKER_ARGS can not be quoted, otherwise it becomes a '' which confuses
|
||||
# docker.
|
||||
exec docker run $DOCKER_ARGS --rm=true -v "${grpc_java_dir}":/grpc-java -w /grpc-java \
|
||||
grpc-java-artifacts \
|
||||
$docker_image \
|
||||
bash -c "function fixFiles() { chown -R $(id -u):$(id -g) /grpc-java; }; trap fixFiles EXIT; $(quote "$@")"
|
||||
|
|
|
|||
|
|
@ -58,7 +58,10 @@ model {
|
|||
cppCompiler.executable = 'aarch64-linux-gnu-g++'
|
||||
linker.executable = 'aarch64-linux-gnu-g++'
|
||||
}
|
||||
target("s390_64")
|
||||
target("s390_64") {
|
||||
cppCompiler.executable = 's390x-linux-gnu-g++'
|
||||
linker.executable = 's390x-linux-gnu-g++'
|
||||
}
|
||||
target("loongarch_64")
|
||||
}
|
||||
clang(Clang) {
|
||||
|
|
|
|||
|
|
@ -68,6 +68,10 @@ checkArch ()
|
|||
format="$(powerpc64le-linux-gnu-objdump -f "$1" | grep -o "file format .*$" | grep -o "[^ ]*$")"
|
||||
echo Format=$format
|
||||
assertEq "$format" "elf64-powerpcle" $LINENO
|
||||
elif [[ "$ARCH" == s390_64 ]]; then
|
||||
format="$(s390x-linux-gnu-objdump -f "$1" | grep -o "file format .*$" | grep -o "[^ ]*$")"
|
||||
echo Format=$format
|
||||
assertEq "$format" "elf64-s390" $LINENO
|
||||
else
|
||||
fail "Unsupported arch: $ARCH"
|
||||
fi
|
||||
|
|
@ -121,6 +125,9 @@ checkDependencies ()
|
|||
elif [[ "$ARCH" == ppcle_64 ]]; then
|
||||
dump_cmd='powerpc64le-linux-gnu-objdump -x '"$1"' |grep "NEEDED"'
|
||||
white_list="linux-vdso64\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld64\.so\.2"
|
||||
elif [[ "$ARCH" == s390_64 ]]; then
|
||||
dump_cmd='s390x-linux-gnu-objdump -x '"$1"' |grep "NEEDED"'
|
||||
white_list="linux-vdso64\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld64\.so\.1"
|
||||
fi
|
||||
elif [[ "$OS" == osx ]]; then
|
||||
dump_cmd='otool -L '"$1"' | fgrep dylib'
|
||||
|
|
|
|||
Loading…
Reference in New Issue