-
Notifications
You must be signed in to change notification settings - Fork 218
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
Fix associates compile classpath #1271
base: master
Are you sure you want to change the base?
Fix associates compile classpath #1271
Conversation
well it looks like the same code fails on CI :) so i guess ill look into this -- edit |
rookie mistake, not of course adding the associates java_outputs as an input to the compilation action, thanks for the help debugging @gabrielborglund |
I've tried to work out why the integration tests are failing, no idea ! sorry :/ |
FYI, i believe with this change in place and considering a build graph that looks like this:
the compilation class path will look like this
which is a change from
.... its possible a different angle could be taken and when the java_info for the associate_deps is collected here in compile.bzl then it could be massaged to drop any ABI jars ie set compile_jar to output_jar |
6fd5fe0
to
48404aa
Compare
rebased onto master |
In the latest commit, any associated ABI jars are replaced by the full output class jar so that the associated internal methods can be resolved |
@@ -261,6 +261,7 @@ class KotlinBuilder | |||
} | |||
|
|||
with(root.inputsBuilder) { | |||
addAllClasspath(argMap.optional(KotlinBuilderFlags.FRIEND_PATHS) ?: emptyList()) |
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.
actually i realise i can drop this now since the classpath is built up earlier in the PR
2. When `experimental_strict_associate_dependencies` is disabled, the complete transitive set of compile jars will | ||
be collected for each assoicate target. | ||
""" | ||
jars_depset = None | ||
if (toolchains.kt.experimental_strict_associate_dependencies and | ||
"kt_experimental_strict_associate_dependencies_incompatible" not in ctx.attr.tags): | ||
jars_depset = depset(direct = [a.compile_jar for a in associate[JavaInfo].java_outputs]) | ||
jars_depset = depset(direct = [a.class_jar for a in associate[JavaInfo].java_outputs]) |
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.
This technically changes the default behavior for everyone, is it possible to only enable this when experimental_treat_internal_as_private_in_abi_jars
or experimental_remove_private_classes_in_abi_jars
is enabled?
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.
on the surface of it i agree with you, but isnt the reality that these jars are quite similar without those flags enabled?
im happy to do this tho, thought it might get a bit unwieldy
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.
further thoughts, im actually thinking that i should introduce a third branch instead behind the private_abi_jars related flags and leave the current code untouched where its non transient class jar.... something like
if (not "kt_remove_private_classes_in_abi_plugin_incompatible" in ctx.attr.tags and toolchains.kt.experimental_remove_private_classes_in_abi_jars):
jars_depset = depset(direct = [a.class_jar for a in associate[JavaInfo].java_outputs])
elif (toolchains.kt.experimental_strict_associate_dependencies and
"kt_experimental_strict_associate_dependencies_incompatible" not in ctx.attr.tags):
jars_depset = depset(direct = [a.compile_jar for a in associate[JavaInfo].java_outputs])
else:
jars_depset = depset(transitive = [associate[JavaInfo].compile_jars])
since this is all about compilation avoidance i would be happen just to have the strictest of case be true
2. When `experimental_strict_associate_dependencies` is disabled, the complete transitive set of compile jars will | ||
be collected for each assoicate target. | ||
""" | ||
jars_depset = None | ||
if (toolchains.kt.experimental_strict_associate_dependencies and | ||
"kt_experimental_strict_associate_dependencies_incompatible" not in ctx.attr.tags): | ||
jars_depset = depset(direct = [a.compile_jar for a in associate[JavaInfo].java_outputs]) | ||
jars_depset = depset(direct = [a.class_jar for a in associate[JavaInfo].java_outputs]) |
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 compile/class jar removal needs to also happen for this path as well, otherwise there is a risk of the final Kotlin compilation classpath having both the compile jar and the full class jar on it.
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.
right, ill revisit this 👌
This is a (surprisingly) small PR to resolve #1250.
Any friends mentioned were not added to the classpath so KotlinBuilder now adds them and it keeps the compilation units friends close by adding them to the head of the classpath
Any friends jars that were aded were effectively just the ABI jars so associates.bzl now uses the class jars (which contain any internal declarations)
I had a hard time (ie failed) writing a test for this, i can only be sure the existing mechanism works ok.
Locally i redefined the tool chain to enable the relevant experimental options
with these in place the basic associates test fails, applying these commits makes it pass
an integration test could be added once a release is cut maybe?