Skip to content

Commit

Permalink
Add embedded jdk support for ppc64le
Browse files Browse the repository at this point in the history
This adds support for embedding OpenJDK in bazel for ppc64le.
Azul Systems does not create Zulu/OpenJDK builds for ppc64le, but AdoptOpenjdk.net does.

This PR adds the necessary configs and conditionals and http_file configuration URLs for adoptopenjdk downloads.
The minimize_jdk.sh script needed a slight generalization.

I've been using adoptOpenjdk-embedded bazel for quite a while and can vouch for its stability.

Closes #11436.

PiperOrigin-RevId: 313571170
  • Loading branch information
jayfurmanek authored and copybara-github committed May 28, 2020
1 parent d8dc951 commit 04e073e
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 4 deletions.
24 changes: 24 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,16 @@ http_file(
urls = ["https://mirror.bazel.build/openjdk/azul-zulu11.37.48-ca-jdk11.0.6/zulu11.37.48-ca-jdk11.0.6-linux_aarch64-minimal-b23d4e05466f2aa1fdcd72d3d3a8e962206b64bf-1581690750.tar.gz"],
)

http_file(
name = "openjdk_linux_ppc64le_vanilla",
downloaded_file_path="adoptopenjdk-ppc64le-vanilla.tar.gz",
sha256 = "a417db0295b1f4b538ecbaf7c774f3a177fab9657a665940170936c0eca4e71a",
urls = [
"https://mirror.bazel.build/openjdk/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
"/~https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
],
)

http_file(
name = "openjdk_macos",
downloaded_file_path = "zulu-macos.tar.gz",
Expand Down Expand Up @@ -687,6 +697,20 @@ http_archive(
urls = ["https://mirror.bazel.build/openjdk/azul-zulu11.37.48-ca-jdk11.0.6/zulu11.37.48-ca-jdk11.0.6-linux_aarch64.tar.gz"],
)

# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
http_archive(
name = "remotejdk11_linux_ppc64le_for_testing",
build_file = "@local_jdk//:BUILD.bazel",
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
sha256 = "a417db0295b1f4b538ecbaf7c774f3a177fab9657a665940170936c0eca4e71a",
strip_prefix = "jdk-11.0.7+10",
urls = [
"https://mirror.bazel.build/openjdk/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
"/~https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
],
)

# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
http_archive(
name = "remotejdk11_macos_for_testing",
Expand Down
4 changes: 4 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ filegroup(
"//src/conditions:linux_aarch64": [
"@openjdk_linux_aarch64_vanilla//file",
],
"//src/conditions:linux_ppc64le": [
"@openjdk_linux_ppc64le_vanilla//file",
],
"//conditions:default": [
"@openjdk_linux_vanilla//file",
],
Expand Down Expand Up @@ -758,6 +761,7 @@ filegroup(
"@remote_java_tools_windows_for_testing//:WORKSPACE",
"@remotejdk11_linux_aarch64_for_testing//:WORKSPACE",
"@remotejdk11_linux_for_testing//:WORKSPACE",
"@remotejdk11_linux_ppc64le_for_testing//:WORKSPACE",
"@remotejdk11_macos_for_testing//:WORKSPACE",
"@remotejdk11_win_for_testing//:WORKSPACE",
"@rules_cc//:WORKSPACE",
Expand Down
6 changes: 6 additions & 0 deletions src/conditions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_ppc64le",
values = {"cpu": "ppc"},
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_s390x",
values = {"cpu": "s390x"},
Expand Down
6 changes: 6 additions & 0 deletions src/conditions/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ config_setting(
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_ppc64le",
values = {"cpu": "ppc"},
visibility = ["//visibility:public"],
)

config_setting(
name = "linux_s390x",
values = {"cpu": "s390x"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,19 @@ maybe(
],
)

# This must be kept in sync with the top-level WORKSPACE file.
maybe(
http_archive,
name = "remotejdk11_linux_ppc64le",
build_file = "@local_jdk//:BUILD.bazel",
sha256 = "a417db0295b1f4b538ecbaf7c774f3a177fab9657a665940170936c0eca4e71a",
strip_prefix = "jdk-11.0.7+10",
urls = [
"https://mirror.bazel.com/openjdk/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
"/~https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.7_10.tar.gz",
],
)

# This must be kept in sync with the top-level WORKSPACE file.
maybe(
http_archive,
Expand Down
16 changes: 12 additions & 4 deletions src/minimize_jdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ else
fi
fulljdk=$1
out=$3
ARCH=`uname -p`
if [[ "${ARCH}" == 'ppc64le' ]]; then
FULL_JDK_DIR="jdk*"
DOCS=""
else
FULL_JDK_DIR="zulu*"
DOCS="DISCLAIMER readme.txt"
fi

UNAME=$(uname -s | tr 'A-Z' 'a-z')

Expand All @@ -38,11 +46,11 @@ if [[ "$UNAME" =~ msys_nt* ]]; then
mkdir "tmp.$$"
cd "tmp.$$"
unzip "../$fulljdk"
cd zulu*
cd $FULL_JDK_DIR
./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
--vm=server --strip-debug --no-man-pages \
--output reduced
cp DISCLAIMER readme.txt legal/java.base/ASSEMBLY_EXCEPTION \
cp $DOCS legal/java.base/ASSEMBLY_EXCEPTION \
reduced/
# These are necessary for --host_jvm_debug to work.
cp bin/dt_socket.dll bin/jdwp.dll reduced/bin
Expand All @@ -55,11 +63,11 @@ else
# to the owner stored in the archive - it will try to do that when running as
# root, but fail when running inside Docker, so we explicitly disable it.
tar xf "$fulljdk" --no-same-owner
cd zulu*
cd $FULL_JDK_DIR
./bin/jlink --module-path ./jmods/ --add-modules "$modules" \
--vm=server --strip-debug --no-man-pages \
--output reduced
cp DISCLAIMER readme.txt legal/java.base/ASSEMBLY_EXCEPTION \
cp $DOCS legal/java.base/ASSEMBLY_EXCEPTION \
reduced/
# These are necessary for --host_jvm_debug to work.
if [[ "$UNAME" =~ darwin ]]; then
Expand Down
1 change: 1 addition & 0 deletions src/test/py/bazel/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TestBase(unittest.TestCase):
'rules_proto',
'remotejdk11_linux_for_testing',
'remotejdk11_linux_aarch64_for_testing',
'remotejdk11_linux_ppc64le_for_testing',
'remotejdk11_macos_for_testing',
'remotejdk11_win_for_testing',
'remote_java_tools_darwin_for_testing',
Expand Down
1 change: 1 addition & 0 deletions src/test/shell/testenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ EOF
"remote_java_tools_windows_for_testing"
"remotejdk11_linux_for_testing"
"remotejdk11_linux_aarch64_for_testing"
"remotejdk11_linux_ppc64le_for_testing"
"remotejdk11_macos_for_testing"
"remotejdk11_win_for_testing"
"rules_cc"
Expand Down
1 change: 1 addition & 0 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ alias(
"//src/conditions:windows": "@remotejdk11_win//:jdk",
"//src/conditions:linux_aarch64": "@remotejdk11_linux_aarch64//:jdk",
"//src/conditions:linux_x86_64": "@remotejdk11_linux//:jdk",
"//src/conditions:linux_ppc64le": "@remotejdk11_linux_ppc64le//:jdk",
},
no_match_error = "Could not find a JDK for host execution environment, please explicitly" +
" provide one using `--host_javabase.`",
Expand Down

0 comments on commit 04e073e

Please sign in to comment.