Repository navigation
Description
- Try to build gerrit code review from this commit (75fa62c694c987d1768017131533d7a9aa45b9da) on Linux:
$ bazel build java/com/google/gerrit/server/diff:diff -s
INFO: Analysed target //java/com/google/gerrit/server/diff:diff (37 packages loaded).
INFO: Found 1 target...
SUBCOMMAND: # //java/com/google/gerrit/server/diff:diff [action 'Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor)']
(cd /home/davido/.cache/bazel/_bazel_davido/5c01f4f713b675540b8b424c5c647f63/execroot/gerrit && \
exec env - \
LC_CTYPE=en_US.UTF-8 \
external/local_jdk/bin/java -XX:+TieredCompilation '-XX:TieredStopAtLevel=1' -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/k8-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar-2.params)
Target //java/com/google/gerrit/server/diff:diff up-to-date:
bazel-bin/java/com/google/gerrit/server/diff/libdiff.jar
INFO: Elapsed time: 4.139s, Critical Path: 0.92s
INFO: Build completed successfully, 3 total actions
it will succeed, where the libdiff.jar-2.params - file on Linux is here: http://paste.openstack.org/show/626680.
- From the same gerrit commit, with the same Bazel version, I used 0.8.0-rc2, try to build the same rule on Windows:
$ bazel build java/com/google/gerrit/server/diff:diff -s
SUBCOMMAND: # //java/com/google/gerrit/server/diff:diff [action 'Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor)']
cd C:/msys64/tmp/_bazel_davido/_biltsqa/execroot/gerrit
SET LC_CTYPE=en_US.UTF-8
external/local_jdk/bin/java.exe -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xbootclasspath/p:external/bazel_tools/third_party/java/jdk/langtools/javac-9-dev-r4023-3.jar -jar external/bazel_tools/tools/jdk/JavaBuilder_deploy.jar @bazel-out/x64_windows-fastbuild/bin/java/com/google/gerrit/server/diff/libdiff.jar-2.params
[54 / 55] Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor); 1s worker
ERROR: C:/users/davido/projects/gerrit/java/com/google/gerrit/server/diff/BUILD:1:1: Building java/com/google/gerrit/server/diff/libdiff.jar (17 source files) and running annotation processors (AutoAnnotationProcessor, AutoValueProcessor) failed (Exit 1)
bazel-out\x64_windows-fastbuild\bin\java\com\google\gerrit\server\diff\_javac\diff\libdiff_sourcegenfiles\com\google\gerrit\server\diff\AutoValue_IntraLineDiffArgs.java:105: error: incompatible types: NameKey cannot be converted to Object
&& (this.project.equals(that.project()))
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
Target //java/com/google/gerrit/server/diff:diff failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 44,308s, Critical Path: 4,68s
FAILED: Build did NOT complete successfully
where the libdiff.jar-2.params - file in Windows is here: http://paste.openstack.org/show/626690.
It turns out, that the root cause is missing transitive dependency on gwtorm.jar that was fixed here: [1]. I've created a reproducer: [2].
It seems that the problem is reported by error prone, in compilation unit, that was generated by annotation processor (auto-value). I wrote this issue to improve the misleading error message: #4105.
This issue is to track the different build outcomes on Linux and Windows: success vs. failure, correspondingly.
Activity
davido commentedon Nov 19, 2017
//CC @cushon @damienmg
It seems that inaccuracy and bad buid outcome is caused by error prone. If I disable all checks on Windows by passing this bazel option:
--javacopt=-XepDisableAllChecks, the build succeeds (as it does on Linux without disabling error prone checks):cushon commentedon Nov 19, 2017
Do you have a minimal repro for the part of this that only happens on windows?
I don't have access to a windows machine right now, would you mind adding
javacopts = ["-verbose"]to//java/com/google/gerrit/server/diff:diffand then sharing the log output for that action for both windows and linux?davido commentedon Nov 19, 2017
@cushon Sure, it took me quite some time to extract the minimal reproducer for this breakage from Gerrit Code Review and gwtorm. See this repro https://github.com/davido/bazel-annotation-processor-breakage. I also was able to eliminate all external deps, except
auto-value.I also filed this issue upstream: [1].
Looking into the verbose output, as expected, the root cause is the missing dependency on indirect dependency on Windows on
gwtorm:client:Windows
Whereas on Linux indirect dependency on
gwtorm:clientis there:Linux
cushon commentedon Nov 20, 2017
Thanks for taking the time to make the repro! I think there's a second bug here preventing
gwtorm:clientfrom being on the classpath for the windows build.Can you share the contents of
bazel-bin/java/com/google/gerrit/reviewdb/libserver-hjar.jdepsfrom the windows build? And do either of--java_classpath=offor--nojava_header_compilationmake a difference?davido commentedon Nov 20, 2017
Here is the content of bazel-bin/java/com/google/gerrit/reviewdb/libserver-hjar.jdeps:
Indeed, passing
--java_classpath=offdid fix it:Passing
--nojava_header_compilationdidn't fix it:cushon commentedon Nov 20, 2017
Can you attach
libserver-hjar.jdepsto the bug? It's a binary proto.davido commentedon Nov 20, 2017
Done libserver-hjar.zip.
cushon commentedon Nov 20, 2017
JavaBuildercompares paths as strings when computing reduced class paths. The params file contains/-separated paths likebazel-out/msvc_x64-fastbuild/bin/java/com/google/gwtorm/libclient-hjar.jar, and the jdeps files contain\-separated paths likebazel-out\msvc_x64-fastbuild\bin\java\com\google\gwtorm\libclient-hjar.jar.cushon commentedon Nov 20, 2017
@meteorcloudy - I'm surprised Bazel is using
/-separated paths for params files on Windows (see the paste in the original comment: http://paste.openstack.org/show/626690/). Is that expected behaviour?meteorcloudy commentedon Nov 21, 2017
Yes, for some reasons we still use
/as seperator, I think it should work fine on Windows with Java.bazel/src/main/java/com/google/devtools/build/lib/vfs/WindowsPathFragment.java
Lines 53 to 58 in 755e176
I wonder where does
\come from?FYI, @laszlocsomor
cushon commentedon Nov 21, 2017
The
\comes from JavaBuilder, which is writing out a.jdepsproto containing paths to some of the entries on the classpath. Those paths round-trip throughjava.nio.file.Path, which uses the platform default path separator when they get converted back to strings.Out of curiosity, why is
/still used on Windows?laszlocsomor commentedon Nov 21, 2017
@meteorcloudy : FYI, I didn't add that TODO, @haxorz did.
19 remaining items
davido commentedon Nov 23, 2017
@cushon As you suggested, the workaround is here: [1]. I tested it with my reproducer on both platforms Linux and Windows. It works as expected.
laszlocsomor commentedon Nov 23, 2017
@davido, thanks for your patch!
I'm looking at changing the path separators for Windows. I expect it will break some tests I'm not yet aware of.
dslomov commentedon Nov 23, 2017
Our release policy is clear: not a regression => no cherry-pick and no release blockage (https://bazel.build/support.html#releases)
Given that this survived at least one release, the problem is not that acute.
dslomov commentedon Nov 23, 2017
The more uniform platform-independent commands are, the better (for remote execution, action cache, etc).
The present issue is in Java tools - Bazel gives valid (on Windows) command lines to Java tools, and Java tools do not handle them correctly- so let's fix it there.
davido commentedon Nov 24, 2017
OTOH, The release policy is also claiming that:
Given that nothing causes more pain, frustration, and disappointment than unfulfilled expectations. As mentioned in the original report to this issue,
Linux
Windows
Needless to say, I was shocked to find out, that a simple
java_libraryrule -- no any system specifics likegenruleor what not involved -- works on Linux and is failing on Windows.So my POV that we are talking about critical and high-impact bug: reliability and accuracy of build outcome. What else can compromise a build tool, when its outcome is flaky?
Very recently, Bazel team removed the notice from the FAQ, that Bazel on Windows platform is highly experimented, bleeding edge and may produce unexpected results.
Last but not least, Bazel has this slogan on its main page:
I suggest, you remove reliably untill
bazel build foofor simplejava_libraryrule produces the same (!) results on all supported platforms. Or your stop claiming that platform X is 100% supported platform, unless you have opened issues (with existing workarounds that you are rejecting to cherry-pick) causing transitive classpath computation to be inherently broken. IOW, revert this CL.I'm really not amused with your assessment of that issue (as you may have noticed). One reason for it, is because Gerrit Code Review project's founder promissed me in person that Bazel team is going to be very supportive for Gerrit Code Review issues, for reasons (that I'm not going to enter into here).
dslomov commentedon Nov 24, 2017
David, I agree this is an important bug to fix, and we will fix it. I think it should block the next (0.9) release.
On the other hand, every software project has bugs, and whenever the user is hit by a bug, that bug is, for that user, the most important thing and the biggest fault of the project ("the sky is falling").
In this case, we just have no evidence that many users are hit by this specific issue: the issue is not a regression, it has been present in more than one release, we build multiple large projects with Bazel very regularly (including on ci.bazel.build), we have multiple large customers with substantial Java codebases, and nobody yet complained. There are workarounds (disable errorprone) that will get you through until this issue is fixed. There is no justification whatsoever to block 0.8 release on this.
davido commentedon Nov 25, 2017
I was looking into adding a test, for the CL above, as was requested in review. It seems that a similar test already exists. So that I was curious, whether or not this test still works with the diff applied.
Unfortunately, the
java_toolsdon't work here. I wrote this issue: #4165.meteorcloudy commentedon Nov 27, 2017
@davido There is a internal change under review from @cushon, which will fix this problem in a more principle way, maybe we can just wait for that one. :)
davido commentedon Nov 27, 2017
@meteorcloudy @cushon
Thanks. I abandoned my CL.
Use java.nio.file.Paths instead of strings in JavaBuilder
cushon commentedon Nov 28, 2017
The work-around was submitted as 0b2352d.
davido commentedon Nov 28, 2017
Works like a charm, thanks!
laszlocsomor commentedon Nov 28, 2017
Update:
\on Windows, but gave up because there are hundreds of call sites and I didn't want to go ahead and audit all, and also:tomlu commentedon Nov 28, 2017