Skip to content

Commit

Permalink
Add embedded jdk support for s390x
Browse files Browse the repository at this point in the history
This patch follows a similar approach used in PR
bazelbuild#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.
  • Loading branch information
Ruixin Bao committed Jul 27, 2020
1 parent e6cce76 commit 09e2421
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 1 deletion.
36 changes: 36 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand All @@ -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",
],
Expand All @@ -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",
],
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/minimize_jdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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',
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 @@ -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"
Expand Down
1 change: 1 addition & 0 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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.`",
Expand Down

0 comments on commit 09e2421

Please sign in to comment.