From 09e24212099adfba8e144517cca8eaae3deb2aef Mon Sep 17 00:00:00 2001 From: Ruixin Bao Date: Thu, 23 Jul 2020 12:38:56 -0700 Subject: [PATCH] Add embedded jdk support for s390x This patch follows a similar approach used in PR https://github.com/bazelbuild/bazel/pull/11436 to add support for embedding OpenJDK in bazel on s390x. Similar to ppc, the openjdk used will be downloadded from adoptopenjdk website. Another thing this PR does is to provide the cached version of allmodules_jdk and minimal_jdk zip files built on s390x. I have tested by linking the files locally on s390x and with these zip files provided, tests no longer fail with java exec format error on s390x. --- WORKSPACE | 36 +++++++++++++++++++ src/BUILD | 10 ++++++ .../build/lib/bazel/rules/java/jdk.WORKSPACE | 12 +++++++ src/minimize_jdk.sh | 2 +- src/test/py/bazel/test_base.py | 1 + src/test/shell/testenv.sh | 1 + tools/jdk/BUILD | 1 + 7 files changed, 62 insertions(+), 1 deletion(-) diff --git a/WORKSPACE b/WORKSPACE index 815adc8b01763f..141525dd08f45a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -360,6 +360,29 @@ http_file( ], ) +http_file( + name = "openjdk_linux_s390x", + downloaded_file_path = "adoptopenjdk-s390x.tar.gz", + sha256 = "c74dd2803dca8185e0a74d9ab47442454e0c500bcbdfaf485bfc90b4d87aee2b", + urls = ["file:///home/peterbao/allmodules_jdk.tar.gz"], +) + +http_file( + name = "openjdk_linux_s390x_minimal", + downloaded_file_path = "adoptopenjdk-s390x-minimal.tar.gz", + sha256 = "fe9403e956a87b0d8fc7ad55a841d6e4718d364603d652d9443d59c0b3544553", + urls = ["file:///home/peterbao/minimal_jdk.tar.gz"], +) + +http_file( + name = "openjdk_linux_s390x_vanilla", + downloaded_file_path="adoptopenjdk-s390x-vanilla.tar.gz", + sha256 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059", + urls = [ + "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.7_10.tar.gz", + ], +) + http_file( name = "openjdk_macos", downloaded_file_path = "zulu-macos.tar.gz", @@ -758,6 +781,19 @@ http_archive( ], ) +# 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_s390x_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 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059", + strip_prefix = "jdk-11.0.7+10", + urls = [ + "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_s390x_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 204dc18110c2a0..9c45e8ded60967 100644 --- a/src/BUILD +++ b/src/BUILD @@ -182,6 +182,9 @@ filegroup( "//src/conditions:linux_aarch64": [ "@openjdk_linux_aarch64//file", ], + "//src/conditions:linux_s390x": [ + "@openjdk_linux_s390x//file", + ], "//conditions:default": [ "@openjdk_linux//file", ], @@ -204,6 +207,9 @@ filegroup( "//src/conditions:linux_aarch64": [ "@openjdk_linux_aarch64_minimal//file", ], + "//src/conditions:linux_s390x": [ + "@openjdk_linux_s390x_minimal//file", + ], "//conditions:default": [ "@openjdk_linux_minimal//file", ], @@ -229,6 +235,9 @@ filegroup( "//src/conditions:linux_ppc64le": [ "@openjdk_linux_ppc64le_vanilla//file", ], + "//src/conditions:linux_s390x": [ + "@openjdk_linux_s390x_vanilla//file", + ], "//conditions:default": [ "@openjdk_linux_vanilla//file", ], @@ -765,6 +774,7 @@ filegroup( "@remotejdk11_linux_aarch64_for_testing//:WORKSPACE", "@remotejdk11_linux_for_testing//:WORKSPACE", "@remotejdk11_linux_ppc64le_for_testing//:WORKSPACE", + "@remotejdk11_linux_s390x_for_testing//:WORKSPACE", "@remotejdk11_macos_for_testing//:WORKSPACE", "@remotejdk11_win_for_testing//:WORKSPACE", "@remotejdk14_linux_for_testing//:WORKSPACE", 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 c62cf98b9380dd..bcf160febea3e3 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 @@ -130,6 +130,18 @@ maybe( ], ) +# This must be kept in sync with the top-level WORKSPACE file. +maybe( + http_archive, + name = "remotejdk11_linux_s390x", + build_file = "@local_jdk//:BUILD.bazel", + sha256 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059", + strip_prefix = "jdk-11.0.7+10", + urls = [ + "https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_s390x_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 52e1c79922f93b..f4f08d94cf4e94 100755 --- a/src/minimize_jdk.sh +++ b/src/minimize_jdk.sh @@ -31,7 +31,7 @@ fi fulljdk=$1 out=$3 ARCH=`uname -p` -if [[ "${ARCH}" == 'ppc64le' ]]; then +if [[ "${ARCH}" == 'ppc64le' ]] || [[ "${ARCH}" == 's390x' ]]; then FULL_JDK_DIR="jdk*" DOCS="" else diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py index baf730325a1c7c..5ba2382919e070 100644 --- a/src/test/py/bazel/test_base.py +++ b/src/test/py/bazel/test_base.py @@ -59,6 +59,7 @@ class TestBase(unittest.TestCase): 'remotejdk11_linux_for_testing', 'remotejdk11_linux_aarch64_for_testing', 'remotejdk11_linux_ppc64le_for_testing', + 'remotejdk11_linux_s390x_for_testing', 'remotejdk11_macos_for_testing', 'remotejdk11_win_for_testing', 'remotejdk14_linux_for_testing', diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh index a1cbb9d4a24afa..a59be7ff9ac0a0 100755 --- a/src/test/shell/testenv.sh +++ b/src/test/shell/testenv.sh @@ -297,6 +297,7 @@ EOF "remotejdk11_linux_for_testing" "remotejdk11_linux_aarch64_for_testing" "remotejdk11_linux_ppc64le_for_testing" + "remotejdk11_linux_s390x_for_testing" "remotejdk11_macos_for_testing" "remotejdk11_win_for_testing" "remotejdk14_linux_for_testing" diff --git a/tools/jdk/BUILD b/tools/jdk/BUILD index 9f08da01d010fb..116b8ebef3ce6a 100644 --- a/tools/jdk/BUILD +++ b/tools/jdk/BUILD @@ -504,6 +504,7 @@ alias( "//src/conditions:linux_aarch64": "@remotejdk11_linux_aarch64//:jdk", "//src/conditions:linux_x86_64": "@remotejdk11_linux//:jdk", "//src/conditions:linux_ppc64le": "@remotejdk11_linux_ppc64le//:jdk", + "//src/conditions:linux_s390x": "@remotejdk11_linux_s390x//:jdk", }, no_match_error = "Could not find a JDK for host execution environment, please explicitly" + " provide one using `--host_javabase.`",