Skip to content

feat(kotlin): extend abi compile-avoidance to mixed kotlin+java targets#36

Open
Alan Wisper (wisper-dev) wants to merge 2 commits into
mainfrom
feat/abi-avoidance-mixed-java
Open

feat(kotlin): extend abi compile-avoidance to mixed kotlin+java targets#36
Alan Wisper (wisper-dev) wants to merge 2 commits into
mainfrom
feat/abi-avoidance-mixed-java

Conversation

@wisper-dev

Copy link
Copy Markdown
Member

Do not merge until an Elide release containing elide-dev/WHIPLASH#1157
(mixed --abi-only) is published.
Until then //e2e/abi_avoidance is red in
CI: the release pinned in versions.bzl cannot yet emit Java ABI for mixed
targets. After the release, bump versions.bzl to it (+ sha256 for all four
platforms) and CI goes green.

Why

After elide-dev/WHIPLASH#1157, elide kotlinc --abi-only emits both the Kotlin
and 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_ijar jar and got no pruning.

What changes

  • elide/private/compile_common.bzl: drop the and not has_java gate — with
    --//config/kotlinc:abi_compile_avoidance on, mixed targets also emit the
    --abi-only header action and use it as JavaInfo.compile_jar.
  • tests/kotlin_rule_test.bzl: _abi_avoidance_mixed_fallback_test is renamed to
    _abi_avoidance_mixed_test and flipped — it now asserts exactly one
    --abi-only action and an _abi.jar compile_jar.
  • e2e/abi_avoidance/run.sh: the mixed assertion now expects both the Kotlin and
    Java ABI.

Still opt-in via --//config/kotlinc:abi_compile_avoidance; no change without it.

Testing (locally, against a build with the WHIPLASH#1157 capability)

  • Bazel analysis: the full //tests:kotlin_rule_tests suite passes 12/12
    (including the flipped mixed test and the unchanged kt-only test).
  • e2e run.sh against 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.bzl to a release that includes elide-dev/WHIPLASH#1157.

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`.
Copilot AI review requested due to automatic review settings June 25, 2026 03:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ElideKotlincAbi action and _abi.jar compile 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_avoidance now applies to mixed kt+java targets, but the ElideKotlincAbi action still only passes kt_srcs (and declares only kt_srcs as 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 .java files 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.

Comment thread tests/kotlin_rule_test.bzl
@codspeed-hq

codspeed-hq Bot commented Jun 25, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 9 untouched benchmarks


Comparing feat/abi-avoidance-mixed-java (89654a5) with main (0972f13)

Open in CodSpeed

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants