[BUILD] Override default java toolchain to remove -parameters flag.

For workaround bazelbuild/bazel#8772 with Bazel >= 0.29.1
TensorFlow still targets Java 1.7 (See JAVACOPTS), which doesn't support
"-parameters" flag. Starting from Java 11 (default since Bazel 0.29.1),
a warning
message will be thrown if "-parameters" is passed. If "-Werror" also
exists,
the compiling action will fail. To workaround this, we override the misc
value of
the default java toolchain to remove "-parameters" flag.
This commit is contained in:
Tongxuan Liu 2023-04-03 20:04:11 +08:00
parent a8b9d0eec4
commit 3bb7a30148
3 changed files with 23 additions and 0 deletions

View File

@ -111,6 +111,10 @@ build --define framework_shared_object=true
build --define open_source_build=true
test --define open_source_build=true
# For workaround https://github.com/bazelbuild/bazel/issues/8772 with Bazel >= 0.29.1
build --java_toolchain=//third_party/toolchains/java:tf_java_toolchain
build --host_java_toolchain=//third_party/toolchains/java:tf_java_toolchain
# Please note that OneDNN on MacOS or windows is still not supported.
# If you would like to use a local OneDNN instead of downloading, please set the
# environment variable "TF_MKL_ROOT" every time before build.

View File

@ -205,6 +205,7 @@ tensorflow/third_party/toolchains/cpus/arm/arm_compiler_configure.bzl
tensorflow/third_party/toolchains/cpus/arm/cc_config.bzl.tpl
tensorflow/third_party/toolchains/cpus/py/BUILD
tensorflow/third_party/toolchains/cpus/py3/BUILD
tensorflow/third_party/toolchains/java/BUILD
tensorflow/third_party/toolchains/preconfig/centos6/cuda10.0-cudnn7/cuda/BUILD
tensorflow/third_party/toolchains/preconfig/centos6/cuda10.0-cudnn7/cuda/build_defs.bzl
tensorflow/third_party/toolchains/preconfig/centos6/cuda10.1-cudnn7/cuda/BUILD

18
third_party/toolchains/java/BUILD vendored Normal file
View File

@ -0,0 +1,18 @@
# For workaround https://github.com/bazelbuild/bazel/issues/8772 with Bazel >= 0.29.1
# TensorFlow still targets Java 1.7 (See JAVACOPTS in tensorflow/java/build_defs.bzl)
# which doesn't support "-parameters" flag. Starting from Java 11 (default since Bazel
# 0.29.1), a warning message will be thrown if "-parameters" is passed. If "-Werror" also exists,
# the compiling action will fail. To workaround this, we override the misc value of
# the default java toolchain to remove "-parameters" flag.
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
licenses(["notice"])
default_java_toolchain(
name = "tf_java_toolchain",
misc = [
"-XDskipDuplicateBridges=true",
"-g",
],
visibility = ["//visibility:public"],
)