-
Notifications
You must be signed in to change notification settings - Fork 264
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
Add jvm_flags attribute test cases to expose issue building javac command line #101
Add jvm_flags attribute test cases to expose issue building javac command line #101
Conversation
Can one of the admins verify this patch? |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
With this diff, I now get what looks like the correct command line for javac, but the following error: diff --git i/scala/scala.bzl w/scala/scala.bzl
index debac4a..aacef5f 100644
--- i/scala/scala.bzl
+++ w/scala/scala.bzl
@@ -202,6 +202,7 @@ SourceJars: {srcjars}
[ctx.outputs.manifest,
ctx.file._ijar,
ctx.file._java,
+ ctx.file._javac,
argfile])
ctx.action(
inputs=ins,
diff --git i/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java w/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java
index 628b569..1298fda 100644
--- i/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java
+++ w/src/java/io/bazel/rulesscala/scalac/ScalaCInvoker.java
@@ -274,6 +274,7 @@ public class ScalaCInvoker {
private static void compileJavaSources(CompileOptions ops, Path tmpPath) throws IOException, InterruptedException {
StringBuilder cmd = new StringBuilder();
cmd.append(ops.javacPath);
+ cmd.append(" ");
if (ops.jvmFlags != "") cmd.append(ops.jvmFlags);
if (ops.javacOpts != "") cmd.append(ops.javacOpts);
|
I guess the issue is here: this approach of gluing args onto the command is probably broken. Probably better to use this method instead: then we can add the args we need rather than string manipulation. |
cfa1cbd
to
ec1440f
Compare
I expect #104 to fix this. |
@petemounce can you merge master and see if the test goes green? I hope so, and then I'll merge. |
@johnynek I rebased just now. |
Huh. A test failed:
Building twice does not produce the same output, but only with this change, it seems. :/ |
This reverts commit 3340a06 (because I made it to the wrong branch)
Locally (OSX 10.12), all the tests pass. |
just to check, you did: https://github.com/bazelbuild/rules_scala/blob/master/test_run.sh clearly this is a test-only change, so if it fails, it is not a problem with the PR, but an actual bug. If the code is non-identical on multiple runs, this usually means the caching is going to be broken and cause unneeded recomputation when there are non-semantic changes to the code (whitespace, for instance). |
Yes; here's the output, and a
|
@@ -157,6 +164,13 @@ scala_library( | |||
glob(["src/main/scala/scala/test/mix_java_scala/*.java"]), | |||
jvm_flags = ["-Xms1G", "-Xmx4G"], | |||
) | |||
#Mix java scala | |||
scala_library( | |||
name = "MixJavaScalaLibWithJvmFlags", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petemounce why is this target needed?
Asking for two reasons:
- Nothing depends on it or runs it in the test_run.sh
- The "existing"
MixJavaScalaLib
target also uses thejvm_flags
attribute so other than the name I don't see any difference.
Did this push anything or conversely trying to protect from a regression? If so how is it different from the existing target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh sorry, I think the "existing" one got it from #104 which you rebased on top off.
Any objection to removing this target?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, no objection, I'll do that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - this one has a slightly more explicit name than the other scala+java mix target, which would make a test failure more explicit. In #104, the existing scala+java mix target had the jvm_flags attribute added by itself, so now could fail if there's an issue with mixed compilation or jvm flags.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petemounce sorry for the delay. fair enough. but wdyt about removing the jvm_flags from this target? It's purpose is to check JavaScala mix, the jvm_flags can be tested solely in the new target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was the addition of jvm_flags on a mixed scala+java library that caused the error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, why do we need OtherLibButWithJvmFlags
?
Can we also remove the jvm_flags from MixJavaScalaLib
and only retain it in the new target?
Last question what is protected by MixJavaScalaLibWithJvmFlags
(assuming MixJavaScalaLib
doesn't have jvm_flags)? How is it protected? What test will break?
could you possibly rebase on master and see if the tests are green now? I think they should be. |
I think this might have been handled by #104 |
I think #234 also should put the nail in this. Reopen if there is still an issue. |
This is mentioned in #99, and this is a reproduction for that (but I don't know where to fix it).