feat(kotlin): Karbine ABI compile-avoidance (opt-in) — closes #11#21
Conversation
Add //config/kotlinc:abi_compile_avoidance (default off). When enabled, a kt-only target's JavaInfo.compile_jar comes from a dedicated, codegen-free `elide kotlinc --abi-only` header action instead of java_common.run_ijar. The header is body-stable: a method-body edit yields a byte-identical jar (same digest), so Bazel prunes every dependent rebuild, and dependents key on the fast header action rather than the full compile. const/inline/signature changes still change the header, so pruning stays sound. `elide kotlinc --abi-only` emits Kotlin ABI only, so this is scoped to kt-only targets; mixed kt+java keeps the run_ijar compile jar (mixed-source ABI is filed upstream). Tests: - Analysis tests (//tests): flag-on emits an ElideKotlincAbi `--abi-only` action and wires compile_jar to the `_abi.jar`; mixed kt+java does NOT take the abi path and keeps the ijar. - e2e/abi_avoidance/run.sh: real-elide soundness harness asserting body/ default-arg edits keep the header identical while const/inline/signature edits change it, plus the two --abi-only behaviors the rule relies on (jar output; Kotlin-only on mixed sources).
Merging this PR will not alter performance
|
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Kotlin build optimization that leverages Elide Karbine’s kotlinc --abi-only mode to produce a body-stable ABI/header jar for Kotlin-only targets, allowing Bazel dependents to key off the header jar and avoid rebuild cascades on method-body-only edits.
Changes:
- Introduces
//config/kotlinc:abi_compile_avoidance(default off) to enable ABI compile-avoidance for Kotlin-only targets. - Implements a dedicated
ElideKotlincAbiheader action inrun_kotlincand wiresJavaInfo.compile_jarto the produced_abi.jarwhen enabled (fallback torun_ijarfor mixed kt+java). - Adds analysis tests validating action emission/wiring behavior and an
e2e/abi_avoidanceharness for empirical soundness checks.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tests/kotlin_rule_test.bzl |
Adds analysis tests covering the ABI header action and mixed-source fallback behavior. |
elide/rules/kotlin.bzl |
Routes Kotlin rule JavaInfo.compile_jar through a new compile_jar_override returned from run_kotlinc. |
elide/private/compile_common.bzl |
Implements --abi-only header action generation and supports overriding compile_jar in make_java_info. |
e2e/abi_avoidance/run.sh |
Adds a local soundness script validating header stability vs ABI-affecting edits and key --abi-only behaviors. |
e2e/abi_avoidance/README.md |
Documents the ABI avoidance soundness harness and how/why to run it. |
config/kotlinc/BUILD.bazel |
Adds the new abi_compile_avoidance build setting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Implements #11: consume Elide's Karbine
--abi-onlycapability so dependents key on a body-stable ABI header jar, pruning rebuilds on method-body edits.What
New opt-in build setting
//config/kotlinc:abi_compile_avoidance(default off). When enabled, a kt-onlyelide_kotlin_*target'sJavaInfo.compile_jarcomes from a dedicated, codegen-freeelide kotlinc --abi-onlyheader action instead ofjava_common.run_ijar:run_ijarjar (the "Bug 1" cascade).const/inline/signature changes still change the header, so dependents that need to rebuild still do.Scope
elide kotlinc --abi-onlyemits Kotlin ABI only, so mixed kt+java targets keep therun_ijarjar (correct, just not pruned). Mixed-source support filed upstream as WHIPLASH#1149.Tests (per the issue's "verify empirically" ask)
//tests, CI-gating): flag-on emits theElideKotlincAbi --abi-onlyaction and wirescompile_jarto the_abi.jar; mixed kt+java does not take the abi path and keeps the ijar.e2e/abi_avoidance/run.sh(real-elide soundness harness): asserts body & default-arg edits keep the header identical, whileconst/inline/signature edits change it — plus the two--abi-onlybehaviors the rule relies on (accepts-d <jar>; Kotlin-only on mixed sources). All 7 assertions green against 1.3.4+20260623.Default-off, so zero behavior change until opted in.
//tests/...35/35.