Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cross-compiling for ppc64le platform #9284

Merged
merged 13 commits into from
Jun 23, 2022
4 changes: 4 additions & 0 deletions buildscripts/kokoro/linux_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ cp -r "$LOCAL_MVN_TEMP"/* "$MVN_ARTIFACT_DIR"/
# for aarch64 platform
sudo apt-get install -y g++-aarch64-linux-gnu
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
4 changes: 3 additions & 1 deletion buildscripts/kokoro/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
# ARCH=x86_32 ./buildscripts/kokoro/unix.sh
# For aarch64 arch:
# ARCH=aarch_64 ./buildscripts/kokoro/unix.sh
# For ppc64le arch:
# ARCH=ppcle_64 ./buildscripts/kokoro/unix.sh

# This script assumes `set -e`. Removing it may lead to undefined behavior.
set -exu -o pipefail
Expand Down Expand Up @@ -86,7 +88,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" ]]; then
if [[ "$ARCH" = "aarch_64" || "$ARCH" = "ppcle_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"
Expand Down
3 changes: 3 additions & 0 deletions buildscripts/kokoro/upload_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ LOCAL_OTHER_ARTIFACTS="$KOKORO_GFILE_DIR"/github/grpc-java/artifacts/
# for linux aarch64 platform
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-aarch_64.exe' | wc -l)" != '0' ]]

# for linux ppc64le platform
[[ "$(find "$LOCAL_MVN_ARTIFACTS" -type f -iname 'protoc-gen-grpc-java-*-linux-ppcle_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
Expand Down
2 changes: 2 additions & 0 deletions buildscripts/make_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ else
--prefix="$INSTALL_DIR"
elif [[ "$ARCH" == aarch* ]]; then
./configure --disable-shared --host=aarch64-linux-gnu --prefix="$INSTALL_DIR"
elif [[ "$ARCH" == ppc* ]]; then
./configure --disable-shared --host=powerpc64le-linux-gnu --prefix="$INSTALL_DIR"
fi
# the same source dir is used for 32 and 64 bit builds, so we need to clean stale data first
make clean
Expand Down
5 changes: 4 additions & 1 deletion compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ model {
}
}
gcc(Gcc) {
target("ppcle_64")
target("ppcle_64") {
cppCompiler.executable = 'powerpc64le-linux-gnu-g++'
linker.executable = 'powerpc64le-linux-gnu-g++'
}
target("aarch_64") {
cppCompiler.executable = 'aarch64-linux-gnu-g++'
linker.executable = 'aarch64-linux-gnu-g++'
Expand Down
7 changes: 7 additions & 0 deletions compiler/check-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ checkArch ()
assertEq "$format" "elf64-x86-64" $LINENO
elif [[ "$ARCH" == aarch_64 ]]; then
assertEq "$format" "elf64-little" $LINENO
elif [[ "$ARCH" == ppcle_64 ]]; then
format="$(powerpc64le-linux-gnu-objdump -f "$1" | grep -o "file format .*$" | grep -o "[^ ]*$")"
echo Format=$format
assertEq "$format" "elf64-powerpcle" $LINENO
else
fail "Unsupported arch: $ARCH"
fi
Expand Down Expand Up @@ -108,6 +112,9 @@ checkDependencies ()
elif [[ "$ARCH" == aarch_64 ]]; then
dump_cmd='aarch64-linux-gnu-objdump -x '"$1"' |grep "NEEDED"'
white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-aarch64\.so\.1"
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"
sumitd2 marked this conversation as resolved.
Show resolved Hide resolved
fi
elif [[ "$OS" == osx ]]; then
dump_cmd='otool -L '"$1"' | fgrep dylib'
Expand Down