Skip to content

Commit a3b9bed

Browse files
author
Ruixin Bao
committed
Add embedded jdk support for s390x
This patch follows a similar approach used in PR bazelbuild#11436 to add support for embedding OpenJDK in bazel for s390x. Similar to ppc, the openjdk used will be downloadded from adoptopenjdk website. Another thing this PR does is to also provide the cached version of allmodules_jdk and minimal_jdk zip files built on s390x. I have tested by linking this file locally on s390x machines and with these zip files provided, tests no longer fail with java exec format error on s390x.
1 parent 7cfe416 commit a3b9bed

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

WORKSPACE

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,29 @@ http_file(
360360
],
361361
)
362362

363+
http_file(
364+
name = "openjdk_linux_s390x",
365+
downloaded_file_path = "adoptopenjdk-s390x.tar.gz",
366+
sha256 = "c74dd2803dca8185e0a74d9ab47442454e0c500bcbdfaf485bfc90b4d87aee2b",
367+
urls = ["file:///home/peterbao/allmodules_jdk.tar.gz"],
368+
)
369+
370+
http_file(
371+
name = "openjdk_linux_s390x_minimal",
372+
downloaded_file_path = "adoptopenjdk-s390x-minimal.tar.gz",
373+
sha256 = "fe9403e956a87b0d8fc7ad55a841d6e4718d364603d652d9443d59c0b3544553",
374+
urls = ["file:///home/peterbao/minimal_jdk.tar.gz"],
375+
)
376+
377+
http_file(
378+
name = "openjdk_linux_s390x_vanilla",
379+
downloaded_file_path="adoptopenjdk-s390x-vanilla.tar.gz",
380+
sha256 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059",
381+
urls = [
382+
"https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.7_10.tar.gz",
383+
],
384+
)
385+
363386
http_file(
364387
name = "openjdk_macos",
365388
downloaded_file_path = "zulu-macos.tar.gz",
@@ -757,6 +780,19 @@ http_archive(
757780
],
758781
)
759782

783+
# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
784+
http_archive(
785+
name = "remotejdk11_linux_s390x_for_testing",
786+
build_file = "@local_jdk//:BUILD.bazel",
787+
patch_cmds = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE,
788+
patch_cmds_win = EXPORT_WORKSPACE_IN_BUILD_BAZEL_FILE_WIN,
789+
sha256 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059",
790+
strip_prefix = "jdk-11.0.7+10",
791+
urls = [
792+
"https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.7_10.tar.gz",
793+
],
794+
)
795+
760796
# This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
761797
http_archive(
762798
name = "remotejdk11_macos_for_testing",

src/BUILD

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ filegroup(
182182
"//src/conditions:linux_aarch64": [
183183
"@openjdk_linux_aarch64//file",
184184
],
185+
"//src/conditions:linux_s390x": [
186+
"@openjdk_linux_s390x//file",
187+
],
185188
"//conditions:default": [
186189
"@openjdk_linux//file",
187190
],
@@ -204,6 +207,9 @@ filegroup(
204207
"//src/conditions:linux_aarch64": [
205208
"@openjdk_linux_aarch64_minimal//file",
206209
],
210+
"//src/conditions:linux_s390x": [
211+
"@openjdk_linux_s390x_minimal//file",
212+
],
207213
"//conditions:default": [
208214
"@openjdk_linux_minimal//file",
209215
],
@@ -229,6 +235,9 @@ filegroup(
229235
"//src/conditions:linux_ppc64le": [
230236
"@openjdk_linux_ppc64le_vanilla//file",
231237
],
238+
"//src/conditions:linux_s390x": [
239+
"@openjdk_linux_s390x_vanilla//file",
240+
],
232241
"//conditions:default": [
233242
"@openjdk_linux_vanilla//file",
234243
],
@@ -758,6 +767,7 @@ filegroup(
758767
"@remotejdk11_linux_aarch64_for_testing//:WORKSPACE",
759768
"@remotejdk11_linux_for_testing//:WORKSPACE",
760769
"@remotejdk11_linux_ppc64le_for_testing//:WORKSPACE",
770+
"@remotejdk11_linux_s390x_for_testing//:WORKSPACE",
761771
"@remotejdk11_macos_for_testing//:WORKSPACE",
762772
"@remotejdk11_win_for_testing//:WORKSPACE",
763773
"@rules_cc//:WORKSPACE",

src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ maybe(
130130
],
131131
)
132132

133+
# This must be kept in sync with the top-level WORKSPACE file.
134+
maybe(
135+
http_archive,
136+
name = "remotejdk11_linux_s390x",
137+
build_file = "@local_jdk//:BUILD.bazel",
138+
sha256 = "d9b72e87a1d3ebc0c9552f72ae5eb150fffc0298a7cb841f1ce7bfc70dcd1059",
139+
strip_prefix = "jdk-11.0.7+10",
140+
urls = [
141+
"https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.7%2B10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.7_10.tar.gz",
142+
],
143+
)
144+
133145
# This must be kept in sync with the top-level WORKSPACE file.
134146
maybe(
135147
http_archive,

src/minimize_jdk.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fi
3131
fulljdk=$1
3232
out=$3
3333
ARCH=`uname -p`
34-
if [[ "${ARCH}" == 'ppc64le' ]]; then
34+
if [[ "${ARCH}" == 'ppc64le' ]] || [[ "${ARCH}" == 's390x' ]]; then
3535
FULL_JDK_DIR="jdk*"
3636
DOCS=""
3737
else

src/test/py/bazel/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class TestBase(unittest.TestCase):
5959
'remotejdk11_linux_for_testing',
6060
'remotejdk11_linux_aarch64_for_testing',
6161
'remotejdk11_linux_ppc64le_for_testing',
62+
'remotejdk11_linux_s390x_for_testing',
6263
'remotejdk11_macos_for_testing',
6364
'remotejdk11_win_for_testing',
6465
'remote_java_tools_darwin_for_testing',

src/test/shell/testenv.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ EOF
294294
"remotejdk11_linux_for_testing"
295295
"remotejdk11_linux_aarch64_for_testing"
296296
"remotejdk11_linux_ppc64le_for_testing"
297+
"remotejdk11_linux_s390x_for_testing"
297298
"remotejdk11_macos_for_testing"
298299
"remotejdk11_win_for_testing"
299300
"rules_cc"

tools/jdk/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ alias(
504504
"//src/conditions:linux_aarch64": "@remotejdk11_linux_aarch64//:jdk",
505505
"//src/conditions:linux_x86_64": "@remotejdk11_linux//:jdk",
506506
"//src/conditions:linux_ppc64le": "@remotejdk11_linux_ppc64le//:jdk",
507+
"//src/conditions:linux_s390x": "@remotejdk11_linux_s390x//:jdk",
507508
},
508509
no_match_error = "Could not find a JDK for host execution environment, please explicitly" +
509510
" provide one using `--host_javabase.`",

0 commit comments

Comments
 (0)