-
Notifications
You must be signed in to change notification settings - Fork 284
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
Always pass the transitive classpath to the compiler for scala_library #423
Conversation
Matches behavior of java_library
Can one of the admins verify this patch? |
if you do these, which I am pretty opposed to, understand if any transitive jar changes, you will rebuild your whole repo. Coupled with the fact that scala does not work great with ijar (lots of private things can change and still change the ijar), I think this will be a miserable experience for a large repo. I really feel it can't be the default without any options. Why don't you use strict deps in warn mode? Doesn't that get you want you want right now? |
cc @ittaiz |
Here is an old issue on where we are with ijar: we really need to have a better scala-aware ijar, or bazel needs to allow customized comparators/key-functions to see if an artifact has changed. |
Yeah. Except for a bunch of warnings.
Yes, just as it does for Scala with strict deps now. And same for Java, with or without strict deps. (True, Java has better ijar, but still...adding a class or non-private method still triggers a massive recompile.)
Do you see that your transitive path differs substantially from the minimal one? My experience was that it was a < 10% difference in practice. But if there actually are significant real-world benefits, I agree transitivity needs to be optional.
Okay. We could overload An attribute would probably(?) be better.
Hm, good to know. Seems like all method signatures are kept but implementations are removed? Improving that would be great, but TBH it at first glance it doesn't seem awful. I use TypeScript, which keeps private signatures in its .d.ts files (unavoidable, because it doesn't name mangle members and needs to ensure uniqueness.) |
I think users in your situation should use strict deps in warn mode, and use builddozer to fix your build if the warnings bother you. If you don't want this, I'm a bit confused why you want to use bazel at all. |
I understand the theory of direct vs transitive compile-time dependencies. The question is: how much does this happen much in practice? Where compiling A requires B, and compiling B requires C, but compiling A does not require C. For javac at least, it is (apparently?) uncommon enough, that rules_java always includes the transitive path.
You could ask the implementers of java_library the same thing. At the end of the day, I want Scala to be able to work the same as |
@pauldraper it is not the case that you don't get an error with java. Have you tried it? https://gist.github.com/johnynek/857579dfd3ce0b1c437826f496448e16
the build fails without strict deps by default as far as I know. Can you show an example with java that behaves as you want it to behave in scala? |
|
Can you share your bazelrc of baze version? Why do I get different behavior
I wonder?
On Fri, Feb 16, 2018 at 13:26 Paul Draper ***@***.***> wrote:
BUILD
java_library(
name = 'a',
srcs = ['A.java'],
)
java_library(
deps = ['a'],
name = 'b',
srcs = ['B.java'],
)
java_library(
deps = ['b'],
name = 'c',
srcs = ['C.java'],
)
// A.java
package example;
class A {}
// B.java
package example;
class B {
private A a = new A();
}
// C.java
package example;
class C {
private A a = new A();
private B b = new B();
}
$ bazel build c
INFO: Analysed target //:c (9 packages loaded).
INFO: Found 1 target...
INFO: From Executing genrule @bazel_tools//tools/jdk:gen_platformclasspath [for host]:
Note: external/bazel_tools/tools/jdk/DumpPlatformClassPath.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Target //:c up-to-date:
bazel-bin/libc.jar
INFO: Elapsed time: 4.525s, Critical Path: 3.93s
INFO: Build completed successfully, 12 total action
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#423 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdjpOK6lOldDY_Bc0OxSbJ2e3sWMAks5tVg6ZgaJpZM4SHMXC>
.
--
P. Oscar Boykin, Ph.D. | http://twitter.com/posco | http://pobox.com/~boykin
|
When I try your example I get:
The same kind of error I get. Here is my bazel version:
this is with no Are you maybe setting an option in a bazelrc somewhere? |
Sorry, I added the tools/bazel.rc after initially posting. So basically, this "issue" comes down to the fact that for Java java_strict_deps does not affect transitivity, and for Scala it does. I think the right, expected behavior would be Java's, by default. But I would be satisfied at least being able to have that behavior enabable by attribute. |
I think practically there are two issues:
|
I think making the default, unconfigured way of operating match java is mostly fine. I do think there is a practical issue that java compiles much faster and ijar works much better for it. I do think we need an option to preserve the current settings. Lastly, I wonder if we need to work on making a scala specific ijar-like tool. Really something that processes the scala-signature of a jar before sending to ijar. If we could remove some of the unneeded things maybe we would have less recompilation. It's tricky from what I hear. |
Good.
Paul,
If you can confirm or refute what “strict” means in java strict deps that
would be really helpful.
If strict means the current Scala settings (and it’s not deprecated) then
it’s easy to change the default to error and add a note for people wanting
the old behavior to use “strict”.
If strict is an alias of error or is deprecated then I think we need to
open an issue for Bazel itself.
Re a scala specific tool for ijar- that sounds awesome but we (Wix) won’t
have the ability to build it in the near future
…On Sat, 17 Feb 2018 at 19:34 P. Oscar Boykin ***@***.***> wrote:
I think making the default, unconfigured way of operating match java is
mostly fine. I do think there is a practical issue that java compiles much
faster and ijar works much better for it.
I do think we need an option to preserve the current settings.
Lastly, I wonder if we need to work on making a scala specific ijar-like
tool. Really something that processes the scala-signature of a jar before
sending to ijar. If we could remove some of the unneeded things maybe we
would have less recompilation.
It's tricky from what I hear.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#423 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFy2m3UlrPcrDKBv_GrKyxioz3s51ks5tVw2bgaJpZM4SHMXC>
.
|
--strict_java_deps strict, default, and error all have the same behavior https://github.com/bazelbuild/bazel/blob/70c2e051e9b8db92228845b04d10b570ded8bfb7/src/main/java/com/google/devtools/build/lib/rules/java/JavaConfiguration.java#L371 (also, in bazel docs) IDK what the history or plans are for this. If we follow java's use of "off", we could use "strict" to retain current intransivity (this admittedly being different than Java "strict") Or we could use a rule attribute to set intransitivity. Separately, I agree scala-ijar needs a look. I'll take a look over the next couple days and report what I find. |
paul, happy to give you pointers for understandign the issues with scala's pickling (or api extraction) if you're interested |
@pauldraper any chance you can open a bazel side issue for adding a new value "non-transitive" which we'll be able to leverage here? I'd really rather not overload "strict" though I'm not vetoing this proposal |
Seems like @pauldraper has an alternative repo supporting this approach. I my personal goal is to make the default very cache efficient, but if you don't like that, you can use the strict deps setting that would enable this for users that don't care about cache hit rates as much as large users do. |
java_library always includes transitive dependencies, regardless of strict deps.
I think scala_library should work similarly.
And unless I am mistaken, scalac more or less requires essentially the full transitive classpath. There seems to be little practical benefit in ever not including the transitive dependencies.
(FYI, tangentially: The reason I am not just using strict deps anyway is because I don't care enough about its guarantees. Code modifications can break downstream targets. I'm okay with dependency modifications breaking downstream targets.)