feat(kotlin): extend abi compile-avoidance to mixed kotlin+java targets#36
feat(kotlin): extend abi compile-avoidance to mixed kotlin+java targets#36Alan Wisper (wisper-dev) wants to merge 2 commits into
Conversation
With `--abi-only` now emitting both the Kotlin and Java ABI, ABI compile-avoidance can cover mixed kt+java targets, not just kt-only ones. - compile_common.bzl: drop the `not has_java` gate so mixed targets emit the `--abi-only` header action and use it as JavaInfo.compile_jar. - kotlin_rule_test.bzl: the mixed test now asserts the --abi-only action and the `_abi.jar` compile_jar (renamed from the old fallback test). - e2e/abi_avoidance/run.sh: the mixed assertion now expects both Kotlin and Java ABI. Still opt-in via `--//config/kotlinc:abi_compile_avoidance`.
There was a problem hiding this comment.
Pull request overview
This PR extends Bazel/Kotlin ABI compile-avoidance to mixed Kotlin+Java targets by enabling the elide kotlinc --abi-only header path for those targets, and updates analysis + e2e tests to assert the new mixed-target behavior.
Changes:
- Enable ABI compile-avoidance for any target with Kotlin sources (including mixed Kotlin+Java) in
run_kotlinc. - Update Kotlin rule analysis tests to expect an
ElideKotlincAbiaction and_abi.jarcompile jar for mixed fixtures. - Update the ABI-avoidance e2e harness expectations to require both Kotlin and Java ABI output for mixed compilation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
elide/private/compile_common.bzl |
Expands the abi_avoidance gate to include mixed Kotlin+Java targets. |
tests/kotlin_rule_test.bzl |
Flips/renames the mixed ABI avoidance analysis test to expect --abi-only + _abi.jar for mixed targets. |
e2e/abi_avoidance/run.sh |
Updates the mixed-source e2e assertion to require both Kotlin and Java ABI output. |
Comments suppressed due to low confidence (1)
elide/private/compile_common.bzl:300
abi_avoidancenow applies to mixed kt+java targets, but theElideKotlincAbiaction still only passeskt_srcs(and declares onlykt_srcsas direct inputs). For mixed targets this will generate a Kotlin-only header and can drop Java ABI, which is exactly what the change is trying to avoid; it may also fail under sandboxing if.javafiles aren’t declared as inputs but are passed to the compiler.
To make mixed-mode avoidance correct, update the abi-only invocation to include java_srcs both in the argv and in the action inputs (e.g., abi_args.add_all(kt_srcs + java_srcs) and inputs.direct = kt_srcs + java_srcs).
abi_avoidance = ctx.attr._abi_compile_avoidance[BuildSettingInfo].value and has_kt
abi_jar = None
if abi_avoidance:
abi_jar = ctx.actions.declare_file(ctx.label.name + "_abi.jar")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merging this PR will not alter performance
|
…xed targets The abi action passed only `kt_srcs` to `--abi-only`, so a mixed kt+java target would emit a Kotlin-only header and (with avoidance on) use it as compile_jar -- dropping the Java ABI and unsoundly pruning dependents. Add `java_srcs` to the action args and inputs, and assert the Java sources reach the abi action's argv.
Why
After
elide-dev/WHIPLASH#1157,elide kotlinc --abi-onlyemits both the Kotlinand Java ABI, not just Kotlin. ABI compile-avoidance can therefore extend from
kt-only to mixed kt+java targets, which previously fell back to the
body-sensitive
run_ijarjar and got no pruning.What changes
elide/private/compile_common.bzl: drop theand not has_javagate — with--//config/kotlinc:abi_compile_avoidanceon, mixed targets also emit the--abi-onlyheader action and use it asJavaInfo.compile_jar.tests/kotlin_rule_test.bzl:_abi_avoidance_mixed_fallback_testis renamed to_abi_avoidance_mixed_testand flipped — it now asserts exactly one--abi-onlyaction and an_abi.jarcompile_jar.e2e/abi_avoidance/run.sh: the mixed assertion now expects both the Kotlin andJava ABI.
Still opt-in via
--//config/kotlinc:abi_compile_avoidance; no change without it.Testing (locally, against a build with the WHIPLASH#1157 capability)
//tests:kotlin_rule_testssuite passes 12/12(including the flipped mixed test and the unchanged kt-only test).
run.shagainst a binary with the capability: all assertions pass(prune-soundness: body -> same, const/inline/signature -> diff; and
mixed-kt-and-java).
Before merge
Bump
versions.bzlto a release that includeselide-dev/WHIPLASH#1157.