From 04e073e6fba17e6990330074fa48e0069cb4530f Mon Sep 17 00:00:00 2001 From: Jason Furmanek Date: Thu, 28 May 2020 05:48:09 -0700 Subject: [PATCH] Add embedded jdk support for ppc64le 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 --- WORKSPACE | 24 +++++++++++++++++++ src/BUILD | 4 ++++ src/conditions/BUILD | 6 +++++ src/conditions/BUILD.tools | 6 +++++ .../build/lib/bazel/rules/java/jdk.WORKSPACE | 13 ++++++++++ src/minimize_jdk.sh | 16 +++++++++---- src/test/py/bazel/test_base.py | 1 + src/test/shell/testenv.sh | 1 + tools/jdk/BUILD | 1 + 9 files changed, 68 insertions(+), 4 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index c8b46c2b4b420a..77f3262b8deca8 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -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", @@ -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", diff --git a/src/BUILD b/src/BUILD index 0d46818463b214..124585b9fe019a 100644 --- a/src/BUILD +++ b/src/BUILD @@ -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", ], @@ -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", diff --git a/src/conditions/BUILD b/src/conditions/BUILD index dd0b48177bc146..bfc88c8f0d735a 100644 --- a/src/conditions/BUILD +++ b/src/conditions/BUILD @@ -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"}, diff --git a/src/conditions/BUILD.tools b/src/conditions/BUILD.tools index 4d94790f90a3fd..393add726a6ddc 100644 --- a/src/conditions/BUILD.tools +++ b/src/conditions/BUILD.tools @@ -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"}, diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE index 95f7f0b797803e..c5f8ef63b0ffe9 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE @@ -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, diff --git a/src/minimize_jdk.sh b/src/minimize_jdk.sh index fb9186bb7bb389..52e1c79922f93b 100755 --- a/src/minimize_jdk.sh +++ b/src/minimize_jdk.sh @@ -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') @@ -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 @@ -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 diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index 8f92c52b38e334..1909afeb6d488a 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -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', diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh index cd447779bd4f26..46ec437affcf10 100755 --- a/src/test/shell/testenv.sh +++ b/src/test/shell/testenv.sh @@ -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" diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD index cbcff60be3e0de..8d8120a6f13a46 100644 --- a/tools/jdk/BUILD +++ b/tools/jdk/BUILD @@ -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.`",