Skip to content

Commit

Permalink
Automated rollback of bazelbuild@808ec9f and bazelbuild@4c9149d and s…
Browse files Browse the repository at this point in the history
…ome manual merging.

Fixes bazelbuild#6035.

This change rolls back the version of the JDK embedded into Bazel to 9.

*** Reason for rollback ***

Bazel 0.17 still needs to support JDK 8 and we need to roll out nits deprecation behind a flag of some sort.

*** Original change description ***

Clean up Java toolchain configuration

now that JDK 8 host_javabases are no longer supported.

PiperOrigin-RevId: 211953405
  • Loading branch information
lberki authored and Copybara-Service committed Sep 7, 2018
1 parent ca6c1e2 commit 7eb9ea1
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 35 deletions.
18 changes: 9 additions & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -128,36 +128,36 @@ distdir_tar(
# OpenJDK distributions used to create a version of Bazel bundled with the OpenJDK.
http_file(
name = "openjdk_linux",
sha256 = "57fad3602e74c79587901d6966d3b54ef32cb811829a2552163185d5064fe9b5",
sha256 = "f27cb933de4f9e7fe9a703486cf44c84bc8e9f138be0c270c9e5716a32367e87",
urls = [
"https://mirror.bazel.build/openjdk/azul-zulu10.2%2B3-jdk10.0.1/zulu10.2%2B3-jdk10.0.1-linux_x64-allmodules.tar.gz",
"https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-linux_x64-allmodules.tar.gz",
],
)

http_file(
name = "openjdk_macos",
sha256 = "e669c9a897413d855b550b4e39d79614392e6fb96f494e8ef99a34297d9d85d3",
sha256 = "404e7058ff91f956612f47705efbee8e175a38b505fb1b52d8c1ea98718683de",
urls = [
"https://mirror.bazel.build/openjdk/azul-zulu10.2%2B3-jdk10.0.1/zulu10.2%2B3-jdk10.0.1-macosx_x64-allmodules.tar.gz",
"https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-macosx_x64-allmodules.tar.gz",
],
)

http_file(
name = "openjdk_win",
sha256 = "c39e7700a8d41794d60985df5a20352435196e78ecbc6a2b30df7be8637bffd5",
sha256 = "e738829017f107e7a7cd5069db979398ec3c3f03ef56122f89ba38e7374f63ed",
urls = [
"https://mirror.bazel.build/openjdk/azul-zulu10.2%2B3-jdk10.0.1/zulu10.2%2B3-jdk10.0.1-win_x64-allmodules.zip",
"https://mirror.bazel.build/openjdk/azul-zulu-9.0.7.1-jdk9.0.7/zulu9.0.7.1-jdk9.0.7-win_x64-allmodules.zip",
],
)

# The source-code for this OpenJDK can be found at:
# https://openjdk.linaro.org/releases/jdk10-src-1804.tar.xz
# https://openjdk.linaro.org/releases/jdk9-src-1708.tar.xz
http_file(
name = "openjdk_linux_aarch64",
sha256 = "b7098b7aaf6ee1ffd4a2d0371a0be26c5a5c87f6aebbe46fe9a92c90583a84be",
sha256 = "72e7843902b0395e2d30e1e9ad2a5f05f36a4bc62529828bcbc698d54aec6022",
urls = [
# When you update this, also update the link to the source-code above.
"http://openjdk.linaro.org/releases/jdk10-server-release-1804.tar.xz",
"http://openjdk.linaro.org/releases/jdk9-server-release-1708.tar.xz",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,16 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {

try {
builder.addWorkspaceFilePrefix(
ResourceFileLoader.loadResource(BazelRuleClassProvider.class, "tools.WORKSPACE"));
ResourceFileLoader.loadResource(BazelRuleClassProvider.class, "tools.WORKSPACE")
// Hackily select the java_toolchain based on the host JDK version. JDK 8 and
// 9 host_javabases require different toolchains, e.g. to use --patch-module
// instead of -Xbootclasspath/p:.
.replace(
"%java_toolchain%",
isJdk8OrEarlier()
? "@bazel_tools//tools/jdk:toolchain_hostjdk8"
: "@bazel_tools//tools/jdk:toolchain_hostjdk9"));

} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand All @@ -56,4 +65,8 @@ public void init(ConfiguredRuleClassProvider.Builder builder) {
public ImmutableList<RuleSet> requires() {
return ImmutableList.of(CoreRules.INSTANCE);
}

private static boolean isJdk8OrEarlier() {
return Double.parseDouble(System.getProperty("java.class.version")) <= 52.0;
}
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
local_repository(name = "bazel_tools", path = __embedded_dir__ + "/embedded_tools")
bind(name = "cc_toolchain", actual = "@bazel_tools//tools/cpp:default-toolchain")
bind(name = "java_toolchain", actual = "%java_toolchain%")
17 changes: 0 additions & 17 deletions src/main/tools/jdk.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,30 @@ DEPRECATION_MESSAGE = ("Don't depend on targets in the JDK workspace;" +
filegroup(
name = "jni_header",
srcs = ["include/jni.h"],
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
name = "jni_md_header-darwin",
srcs = ["include/darwin/jni_md.h"],
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
name = "jni_md_header-linux",
srcs = ["include/linux/jni_md.h"],
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
name = "jni_md_header-freebsd",
srcs = ["include/freebsd/jni_md.h"],
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
name = "jni_md_header-windows",
srcs = ["include/win32/jni_md.h"],
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
name = "java",
deprecation = DEPRECATION_MESSAGE,
srcs = select({
":windows": ["bin/java.exe"],
"//conditions:default": ["bin/java"],
Expand All @@ -46,7 +40,6 @@ filegroup(

filegroup(
name = "jar",
deprecation = DEPRECATION_MESSAGE,
srcs = select({
":windows": ["bin/jar.exe"],
"//conditions:default": ["bin/jar"],
Expand All @@ -55,7 +48,6 @@ filegroup(
)

filegroup(
deprecation = DEPRECATION_MESSAGE,
name = "javac",
srcs = select({
":windows": ["bin/javac.exe"],
Expand All @@ -65,13 +57,11 @@ filegroup(
)

filegroup(
deprecation = DEPRECATION_MESSAGE,
name = "xjc",
srcs = ["bin/xjc"],
)

filegroup(
deprecation = DEPRECATION_MESSAGE,
name = "wsimport",
srcs = ["bin/wsimport"],
)
Expand All @@ -86,21 +76,18 @@ BOOTCLASS_JARS = [

# TODO(cushon): this isn't compatible with JDK 9
filegroup(
deprecation = DEPRECATION_MESSAGE,
name = "bootclasspath",
srcs = ["jre/lib/%s" % jar for jar in BOOTCLASS_JARS],
)

# TODO(cushon): migrate to extclasspath and delete
filegroup(
name = "extdir",
deprecation = DEPRECATION_MESSAGE,
srcs = glob(["jre/lib/ext/*.jar"]),
)

filegroup(
name = "extclasspath",
deprecation = DEPRECATION_MESSAGE,
srcs = glob(["jre/lib/ext/*.jar"]),
)

Expand All @@ -113,7 +100,6 @@ filegroup(
":windows": glob(["jre/bin/**"], exclude = ["jre/bin/plugin2/**"]),
"//conditions:default": glob(["jre/bin/**"]),
}),
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
Expand All @@ -132,7 +118,6 @@ filegroup(
":jre-bin",
":jre-lib",
],
deprecation = DEPRECATION_MESSAGE,
)

filegroup(
Expand Down Expand Up @@ -174,14 +159,12 @@ java_runtime(
filegroup(
name = "langtools",
srcs = ["lib/tools.jar"],
deprecation = DEPRECATION_MESSAGE,
)

java_import(
name = "langtools-neverlink",
jars = ["lib/tools.jar"],
neverlink = 1,
deprecation = DEPRECATION_MESSAGE,
)

config_setting(
Expand Down
14 changes: 13 additions & 1 deletion src/test/shell/integration/execution_phase_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ function assert_cache_stats() {
#### TESTS #############################################################

function test_cache_computed_file_digests_behavior() {
# Does not work on Windows, https://github.com/bazelbuild/bazel/issues/6098
return

local -r pkg="${FUNCNAME}"
mkdir -p "$pkg" || fail "could not create \"$pkg\""

Expand Down Expand Up @@ -165,7 +168,9 @@ EOF
assert_cache_stats "miss count" 1 # volatile-status.txt
}

function IGNORED_test_cache_computed_file_digests_uncaught_changes() {
function test_cache_computed_file_digests_uncaught_changes() {
return

local timestamp=201703151112.13 # Fixed timestamp to mark our file with.

mkdir -p package || fail "mkdir failed"
Expand Down Expand Up @@ -225,6 +230,9 @@ EOF
}

function test_cache_computed_file_digests_ui() {
# Does not work on Windows, https://github.com/bazelbuild/bazel/issues/6098
return

local -r pkg="${FUNCNAME}"
mkdir -p "$pkg" || fail "could not create \"$pkg\""

Expand All @@ -249,6 +257,8 @@ function test_cache_computed_file_digests_ui() {
}

function test_jobs_default_auto() {
return

local -r pkg="${FUNCNAME}"
mkdir -p "$pkg" || fail "could not create \"$pkg\""

Expand All @@ -269,6 +279,8 @@ function test_jobs_default_auto() {
}

function test_analysis_warning_cached() {
return

mkdir -p "foo" "bar" || fail "Could not create directories"
cat > foo/BUILD <<'EOF' || fail "foo/BUILD"
cc_library(
Expand Down
3 changes: 3 additions & 0 deletions src/test/shell/integration/server_logging_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ fi
#### TESTS #############################################################

function test_log_file_uses_single_line_formatter() {
# Does not work on Windows, https://github.com/bazelbuild/bazel/issues/6098
return

local client_log="$(bazel info output_base)/java.log"

# Construct a regular expression to match a sample message in the log using
Expand Down
16 changes: 11 additions & 5 deletions tools/jdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ load(
"//tools/jdk:default_java_toolchain.bzl",
"default_java_toolchain",
"java_runtime_files",
"JDK8_JVM_OPTS",
"JDK9_JVM_OPTS",
"DEFAULT_JAVACOPTS",
)

Expand Down Expand Up @@ -191,7 +193,7 @@ alias(
actual = "@embedded_jdk//:jdk",
)

RELEASES = (8, 9, 10)
RELEASES = (8, 9)

# Create jars containing compile-time bootclasspaths for each Java version
# in RELEASES, using javac to read those APIs via the infrastructure added
Expand Down Expand Up @@ -221,30 +223,34 @@ rm -rf $$TMPDIR
default_java_toolchain(
name = "toolchain_hostjdk8",
bootclasspath = [":platformclasspath8"],
forcibly_disable_header_compilation = True,
javabuilder = [":vanillajavabuilder"],
jvm_opts = [],
jvm_opts = JDK8_JVM_OPTS,
source_version = "8",
target_version = "8",
)

# Default to the Java 8 language level.
# TODO(cushon): consider if/when we should increment this?
alias(
name = "toolchain",
name = "toolchain_hostjdk9",
actual = "toolchain_java8",
)

[
default_java_toolchain(
name = "toolchain_java%d" % release,
bootclasspath = [":platformclasspath%d" % release],
jvm_opts = JDK9_JVM_OPTS,
source_version = "%s" % release,
target_version = "%s" % release,
)
for release in RELEASES
]

alias(
name = "toolchain",
actual = "//external:java_toolchain",
)

filegroup(
name = "srcs",
srcs = [
Expand Down
8 changes: 6 additions & 2 deletions tools/jdk/default_java_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

"""Bazel rules for creating Java toolchains."""

JVM_OPTS = [
JDK8_JVM_OPTS = [
"-Xbootclasspath/p:$(location @bazel_tools//third_party/java/jdk/langtools:javac_jar)",
]

JDK9_JVM_OPTS = [
# In JDK9 we have seen a ~30% slow down in JavaBuilder performance when using
# G1 collector and having compact strings enabled.
"-XX:+UseParallelOldGC",
Expand Down Expand Up @@ -70,7 +74,7 @@ DEFAULT_TOOLCHAIN_CONFIGURATION = {
"@bazel_tools//third_party/java/jdk/langtools:jdk_compiler_jar",
],
"javac_supports_workers": 1,
"jvm_opts": JVM_OPTS,
"jvm_opts": JDK8_JVM_OPTS,
"misc": DEFAULT_JAVACOPTS,
"compatible_javacopts": COMPATIBLE_JAVACOPTS,
"singlejar": ["@bazel_tools//tools/jdk:singlejar"],
Expand Down

0 comments on commit 7eb9ea1

Please sign in to comment.