Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building Bazel with JAVA_HOME set to OpenJDK 9 fails. #4709

Closed
philwo opened this issue Feb 26, 2018 · 6 comments
Closed

Building Bazel with JAVA_HOME set to OpenJDK 9 fails. #4709

philwo opened this issue Feb 26, 2018 · 6 comments

Comments

@philwo
Copy link
Member

philwo commented Feb 26, 2018

I'm trying to build Bazel using Bazel itself when JAVA_HOME is set to the official OpenJDK 9 binaries downloaded from http://jdk.java.net/9/.

I get this error:

ERROR: /private/var/tmp/_bazel_philwo/7a01905b4627ca044e5e3f5ad5b14d26/external/local_jdk/BUILD.bazel:165:1: @local_jdk//:langtools-neverlink: missing input file '@local_jdk//:lib/tools.jar'

It seems like langtools-neverlink is only used by //third_party/checker_framework_dataflow and //third_party/checker_framework_javacutil, both of which are only depended on by errorprone.

@cushon How would I fix this? Is there a replacement for tools.jar in JDK9 that checker_framework_dataflow should use?

@cushon
Copy link
Contributor

cushon commented Feb 26, 2018

That should probably be using //third_party/java/jdk/langtools:javac instead of the host JDK's tools.jar anyways. There isn't a direct tools.jar replacement in 9.

Also, those versions of the Checker Framework libraries are out of date. They should be updated to 2.2.2 to match the current version of Error Prone. And I'm not sure why they're being built from source? If they were prebuilts we wouldn't need the neverlink javac dep at all. I recommend updating them to these versions:

@davido
Copy link
Contributor

davido commented Feb 27, 2018

And I'm not sure why they're being built from source?

+1. I have never understood why Bazel building Checker Framework from source?

@davido
Copy link
Contributor

davido commented Mar 8, 2018

I fixed Checker Framework issue, but Bazel build with Java 9 is still broken: [1].

[1] http://paste.openstack.org/show/694663

davido added a commit to davido/bazel that referenced this issue Mar 8, 2018
Change-Id: I2eb1f6d5fffdbe30ad1d25094ebe80d8204cb184
Fixes: bazelbuild#4709.
davido added a commit to davido/bazel that referenced this issue Mar 8, 2018
davido added a commit to davido/bazel that referenced this issue Mar 8, 2018
Fixes: bazelbuild#3410, bazelbuild#4709.

To build bazel with Java 9 issue:

  $ bazel --host_javabase=/usr/lib64/jvm/java-9-openjdk build \
  --javacopt='--release 9' \
  --java_toolchain=@bazel_tools//tools/jdk:toolchain_jdk9 \
  src:bazel

This still doesn't work: [1].

* [1] http://paste.openstack.org/show/694736

Change-Id: Ic529e222344dc894e9d6b853a9551c7a19a52697
@davido
Copy link
Contributor

davido commented Mar 8, 2018

I added another CL to pass --add-modules=jdk.unsupported to the compiler,
and now it is failing later:

  $ bazel --host_javabase=/usr/lib64/jvm/java-9-openjdk build
  \--javacopt='--release 9' \
  \--java_toolchain=@bazel_tools//tools/jdk:toolchain_jdk9 \
  src:bazel
[...]
WARNING: All illegal access operations will be denied in a future release
INFO: From Building src/main/java/com/google/devtools/build/lib/libkeep-going-option.jar (1 source file) and running annotation processors (OptionProcessor):
warning: Supported source version 'RELEASE_8' from annotation processor 'com.google.devtools.common.options.processor.OptionProcessor' less than -source '1.9'
ERROR: /home/davido/projects/bazel/src/main/protobuf/BUILD:102:1: Building src/main/protobuf/libcommand_server_java_grpc.jar (1 source jar) failed (Exit 1)
/com/google/devtools/build/lib/server/CommandServerGrpc.java:20: error: cannot find symbol
@javax.annotation.Generated(
                 ^
  symbol:   class Generated
  location: package javax.annotation
Target //src:bazel failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 106.315s, Critical Path: 28.19s
FAILED: Build did NOT complete successfully

davido added a commit to davido/bazel that referenced this issue Mar 8, 2018
Fixes: bazelbuild#3410, bazelbuild#4709.

To build bazel with Java 9 issue:

  $ bazel --host_javabase=/usr/lib64/jvm/java-9-openjdk build \
  --javacopt='--release 9' \
  --java_toolchain=@bazel_tools//tools/jdk:toolchain_jdk9 \
  src:bazel

This still doesn't work due to gRpc dependency on Java 8 specific
@javax.annotation.Generated annotation: [1].

[1] grpc/grpc-java#3633

Change-Id: Ic529e222344dc894e9d6b853a9551c7a19a52697
@davido
Copy link
Contributor

davido commented Mar 8, 2018

@cushon I added a workaround to use Java 9 @Generated annotation and added the patch to the PR linked to this issue. Now I'm able to build src:bazel with Java 9.

Trying to use Bazel built with Java 9, I'm seeing something strange: the transitive dependency is not correctly detected, and build is aborted. SUT is my bazel_printy repository:

 $ java -version
  openjdk version "9.0.4"
$ bazel build :printy_lib
INFO: Analysed target //:printy_lib (0 packages loaded).
INFO: Found 1 target and 0 test targets...
ERROR: /home/davido/projects/bazel_printy/BUILD:9:1: Building libprinty_lib.jar (1 source file) failed (Exit 1)
src/main/java/org/gerritcon/mv2016/Printy.java:22: error: [strict] Using type com.google.common.base.Joiner from an indirect dependency (TOOL_INFO: "@guava//jar"). See command below **
    System.out.println(Joiner.on(' ').join(argv));
                       ^
 ** Please add the following dependencies: 
  @guava//jar  to //:printy_lib 
 ** You can use the following buildozer command: 
buildozer 'add deps @guava//jar ' //:printy_lib 

Target //:printy_lib failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.481s, Critical Path: 0.32s
FAILED: Build did NOT complete successfully

But, the guava dependency is already there, of course.

Any clue, what is going on here?

If I build Bazel from the same tree with Java 8, basically, most recent master with the PR linked to this issue, but revert gRpc change as javax.annotation.processing.Generated does not exist on Java 8, then all is fine:

$ bazel build :printy_lib
Extracting Bazel installation...
...........
INFO: Analysed target //:printy_lib (10 packages loaded).
INFO: Found 1 target...
Target //:printy_lib up-to-date:
  bazel-bin/libprinty_lib.jar
INFO: Elapsed time: 7.662s, Critical Path: 3.84s
INFO: Build completed successfully, 4 total actions

davido added a commit to davido/bazel that referenced this issue Mar 9, 2018
davido added a commit to davido/bazel that referenced this issue Mar 9, 2018
davido added a commit to davido/bazel that referenced this issue Mar 14, 2018
Fixes: bazelbuild#4709.

This change stops building checker framework from the source and consumes
the artifacts from Central. As the consequence, the sources are removed
from the Bazel tree and we discontinue packaging the sources in Bazel
source artifact.

LGPL sources are still have to be included in embeded_tools archive. The
source jars are included in embedded_tools archive now:

$ unzip -t bazel-genfiles/src/embedded_tools.zip|grep checker_framework
testing: third_party/checker_framework_dataflow/dataflow-2.2.2-sources.jar
testing: third_party/checker_framework_javacutil/javacutil-2.2.2-sources.jar
davido added a commit to davido/bazel that referenced this issue Mar 14, 2018
Fixes: bazelbuild#4709.

This change stops building checker framework from the source and consumes
the artifacts from Central. As the consequence, the sources are removed
from the Bazel tree and we discontinue packaging the sources in Bazel
source artifact.

LGPL sources are still have to be included in embeded_tools archive. The
source jars are included in embedded_tools archive now:

$ unzip -t bazel-genfiles/src/embedded_tools.zip|grep checker_framework
testing: third_party/checker_framework_dataflow/dataflow-2.2.2-sources.jar
testing: third_party/checker_framework_javacutil/javacutil-2.2.2-sources.jar
davido added a commit to davido/bazel that referenced this issue Mar 16, 2018
Fixes: bazelbuild#4709.

This change stops building checker framework from the source and consumes
the artifacts from Central. As the consequence, the sources are removed
from the Bazel tree and we discontinue packaging the sources in Bazel
source artifact.

GPL v2 with Classpath exception sources have to be still included in
third_party:gpl-srcs rule. The source jars are included in this rule,
that is used in embeded_tools archive:

$ unzip -t bazel-genfiles/src/embedded_tools.zip|grep checker_framework
testing: third_party/checker_framework_dataflow/dataflow-2.2.2-sources.jar
testing: third_party/checker_framework_javacutil/javacutil-2.2.2-sources.jar
@cushon
Copy link
Contributor

cushon commented Apr 6, 2018

The checker framework changes happened in 88a0072.

@cushon cushon closed this as completed Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants