update-shim
Skill1.1k starsChanged 5 days agoApache-2.0View on GitHub
Modify, build, publish, and verify the Kotlin/Native shim artifacts (gRPC shim and protobuf shim) in native-deps/shims/. Use this skill whenever the user wants to change shim C/C++ source code, update shim headers or .def files, bump a shim upstream version, add or remove archives from the overlap excludes list, update the annotation module, publish shim artifacts locally, or debug any native shim build failure. Also trigger when the user mentions "shim", "cinterop", "native interop", "grpc shim", "protobuf shim", "overlap archives", "native-deps", "Bazel shim build", or "shim verification".
- Installs packages
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 4 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Use the running_gradle_builds skill for all Gradle build/publish tasks and the running_gradle_tests skill for all Gradle test tasks.
- Distinctive: line 94
When making shim code changes (not upstream bumps), bump only the shim revision (the part after the dash).
- Very specific: line 113
If you added/removed/renamed C functions, update the corresponding .def file to reflect the new API surface.
- Very specific: line 158
Use --write-excludes <file> --exclude-scope <target> to auto-append entries.
- Very specific: line 162
Update the base version in versions-root/libs.versions.toml (e.g., change internal-native-grpc-shim from 1.80.0-1 to 1.81.0-1).
- Very specific: line 174
All tasks in this section target the shims standalone build (projectRoot: native-deps/shims/).
- Very specific: line 204
After publishing locally, build the shim consumers in the main project (default projectRoot) via running_gradle_builds:
- Distinctive: line 210
Use whichever native target matches your host.
- Distinctive: line 215
If you modified archive contents, overlap excludes, or bumped an upstream version:
- Distinctive: line 225
Check Linux targets separately (they have the KRPC-540 symbol rewrite):
- Very specific: line 241
If DEVELOPER_DIR is not set, the build script defaults to /Applications/Xcode.app/Contents/Developer.
- Very specific: line 248
Linux symbol collision at link time: If you see duplicate AbslInternalGetFileMappingHint errors, the KRPC-540 workaround in …
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Updating Native Shims
Native shims are Kotlin/Native cinterop wrappers around third-party C/C++ libraries
(gRPC core and protobuf wire). They live in native-deps/shims/ as a standalone
Gradle build (separate from the main kotlinx-rpc project).
How to Execute
Use the running_gradle_builds skill for all Gradle build/publish tasks and the
running_gradle_tests skill for all Gradle test tasks. Do NOT run ./gradlew
directly via shell.
Because the shims build is a standalone Gradle project, you must set projectRoot
to the absolute path of native-deps/shims/ when invoking Gradle skills for shim
tasks. For verification tasks that run in the main kotlinx-rpc project, use the
default projectRoot (omit it or point to the repo root).
Module Layout
native-deps/shims/
grpc/ # :kotlinx-rpc-grpc-core-shim
src/cpp/kgrpc.cpp # C shim wrapper source
src/nativeInterop/cinterop/
grpcCoreInterop.def # CInterop definition (template — staticLibraries injected at build)
include/kgrpc.h # Shim header
BUILD.bazel # Bazel target :grpc_shim
MODULE.bazel # Bazel module (GRPC_VERSION synced from version catalog)
overlap-archive-excludes.txt # Archives excluded because protobuf-shim already provides them
tools/analyze_overlap.py # Symbol overlap analysis helper
build.gradle.kts
protobuf/ # :kotlinx-rpc-protobuf-shim
src/cpp/protowire.cpp # C shim wrapper source
src/nativeInterop/cinterop/
libprotowire.def # CInterop definition (per-target static libs listed inline)
include/protowire.h # Shim header
BUILD.bazel # Bazel target :protowire_fat
MODULE.bazel # Bazel module (PROTOBUF_VERSION synced from version catalog)
build.gradle.kts
annotation/ # :kotlinx-rpc-native-shims-annotation
src/commonMain/kotlin/
kotlinx/rpc/grpc/internal/shim/InternalNativeRpcApi.kt
kotlinx/rpc/protobuf/internal/shim/InternalNativeProtobufApi.kt
build.gradle.kts
settings.gradle.kts
gradle.properties
native-deps/scripts/
build_target.sh # Runs Bazel for one target, copies static library outThe build helper build_target.sh lives in the sibling native-deps/scripts/
directory (alongside the other native-deps utility scripts). It is still invoked
from each shim module directory (which owns the Bazel workspace) by the
registerNativeShimBazelBuildTask Gradle helper.
The native-deps/grpc-c-prebuilt/ sibling directory publishes raw .a static
archives and headers consumed by the gRPC shim. The protobuf shim builds its own
fat archive via Bazel directly.
Build Pipeline (per shim, per native target)
- Bazel builds a target-specific static library (
build_target.shwrapsbazel build). - Gradle unpacks prebuilt archives (gRPC) or uses the Bazel output directly (protobuf).
- CInterop generates Kotlin bindings from the
.deffile + headers + static libs. - The generated KLIB is published alongside the annotation artifact.
Versioning
Versions live in versions-root/libs.versions.toml:
| Alias | Current | Format |
internal-native-grpc-shim | 1.80.0-1 | <upstream-grpc-version>-<shim-revision> |
internal-native-protobuf-shim | 34.0-1 | <upstream-protobuf-version>-<shim-revision> |
internal-native-shim-annotation | 0.1.0 | Independent semver |
When making shim code changes (not upstream bumps), bump only the shim revision
(the part after the dash). When bumping the upstream library version, update the
base version and reset the shim revision to 1.
The base version is automatically synced to the corresponding MODULE.bazel file
(GRPC_VERSION or PROTOBUF_VERSION variable) by a Gradle task at build time.
Making Changes
Changing C/C++ shim code or headers
The shim C/C++ source lives alongside its Bazel build:
- gRPC:
grpc/src/cpp/kgrpc.cpp+grpc/include/kgrpc.h - Protobuf:
protobuf/src/cpp/protowire.cpp+protobuf/include/protowire.h
After editing:
- If you added/removed/renamed C functions, update the corresponding
.deffile to reflect the new API surface. The.deffile controls what CInterop exposes to Kotlin. - Bump the shim revision in
versions-root/libs.versions.toml. - Build and verify (see sections below).
Changing CInterop definitions
- gRPC:
grpc/src/nativeInterop/cinterop/grpcCoreInterop.def— this is a template. The__STATIC_LIBRARIES__placeholder is replaced at build time with the full archive list from the unpacked gRPC bundle. Edit filter rules, header includes, strict enums, and noStringConversion entries here. - Protobuf:
protobuf/src/nativeInterop/cinterop/libprotowire.def— this file lists per-targetstaticLibrariesinline (onestaticLibraries.{target}entry per native target). Edit header includes and filter rules here.
Changing the annotation module
Annotations live in annotation/src/commonMain/kotlin/. Both are @RequiresOptIn(level = ERROR).
Changes here are rare — typically only when adding a new shim family.
Managing archive overlaps (KRPC-540)
gRPC and protobuf both bundle native Abseil/protobuf archives. When a final binary links both shims, duplicate symbols can cause linker failures (especially on Linux).
Overlap excludes file: grpc/overlap-archive-excludes.txt
- Format:
all:<archive>(every target) or<target>:<archive>(target-specific) - Archives can be named in bundle-manifest form (
lib/foo/bar.a) or flattened interop form (foo+__bar.a) - Currently excludes
utf8_rangefrom gRPC shim since protobuf-shim provides it
Symbol rewrite workaround (Linux only, temporary — remove when protobuf becomes
Kotlin-only): The protobuf shim build rewrites AbslInternalGetFileMappingHint to
KrpcProtobuf_AbslInternalGetFileMappingHint using llvm-objcopy --redefine-sym.
This lives in protobuf/build.gradle.kts.
To investigate new overlaps:
cd native-deps/shims
python3 grpc/tools/analyze_overlap.py \
--grpc-klib <path-to-grpc-cinterop-klib> \
--protobuf-klib <path-to-protobuf-cinterop-klib> \
--target linux_x64Use --write-excludes <file> --exclude-scope <target> to auto-append entries.
Bumping an upstream version
- Update the base version in
versions-root/libs.versions.toml(e.g., changeinternal-native-grpc-shimfrom1.80.0-1to1.81.0-1). - The
MODULE.bazelversion variable is synced automatically by thesyncGrpcVersionToBazelModule/syncProtobufVersionToBazelModuleGradle task. - For gRPC: also update the
grpc-c-prebuiltversion if the prebuilt archive version needs to match. - Build, verify, and check for new symbol overlaps.
Publishing Locally
All tasks in this section target the shims standalone build (projectRoot: native-deps/shims/).
Prerequisite: Bazel (or Bazelisk) must be on PATH. On macOS, Xcode (not just CommandLineTools) should be installed for cross-compilation to iOS/tvOS/watchOS.
Publish to the local build repo
- gRPC shim + annotation: task
:kotlinx-rpc-grpc-core-shim:publishAllPublicationsToNativeDepsBuildRepoRepository :kotlinx-rpc-native-shims-annotation:publishAllPublicationsToNativeDepsBuildRepoRepository - Protobuf shim + annotation: task
:kotlinx-rpc-protobuf-shim:publishAllPublicationsToNativeDepsBuildRepoRepository :kotlinx-rpc-native-shims-annotation:publishAllPublicationsToNativeDepsBuildRepoRepository
Published artifacts land in native-deps/build/repo/. The main kotlinx-rpc project
is configured to resolve from this path during development.
Publish both shims together
Task: :kotlinx-rpc-grpc-core-shim:publishAllPublicationsToNativeDepsBuildRepoRepository :kotlinx-rpc-protobuf-shim:publishAllPublicationsToNativeDepsBuildRepoRepository :kotlinx-rpc-native-shims-annotation:publishAllPublicationsToNativeDepsBuildRepoRepository
Build without publishing (sanity check)
- gRPC shim: task
:kotlinx-rpc-grpc-core-shim:assemble - Protobuf shim: task
:kotlinx-rpc-protobuf-shim:assemble
Verification
1. Verify in the main project
After publishing locally, build the shim consumers in the main project
(default projectRoot) via running_gradle_builds:
- Protobuf shim consumer: task
:protobuf:protobuf-lite:compileKotlinMacosArm64 - gRPC shim consumer: task
:grpc:grpc-core:compileKotlinMacosArm64
Use whichever native target matches your host. If both compile cleanly, the shim changes integrate correctly with the rest of the project.
2. Check for symbol overlaps (when changing archives)
If you modified archive contents, overlap excludes, or bumped an upstream version:
cd native-deps/shims
python3 grpc/tools/analyze_overlap.py \
--grpc-klib build/classes/kotlin/macosArm64/main/cinterop/cinterop-grpcCoreInterop.klib \
--protobuf-klib build/classes/kotlin/macosArm64/main/cinterop/cinterop-libprotowire.klib \
--target macos_arm64Check Linux targets separately (they have the KRPC-540 symbol rewrite):
python3 grpc/tools/analyze_overlap.py \
--grpc-klib build/classes/kotlin/linuxX64/main/cinterop/cinterop-grpcCoreInterop.klib \
--protobuf-klib build/classes/kotlin/linuxX64/main/cinterop/cinterop-libprotowire.klib \
--target linux_x64Troubleshooting
Bazel not found: Install Bazelisk (brew install bazelisk on macOS) — it
manages Bazel versions automatically.
Xcode issues on macOS: The build needs full Xcode for Apple platform SDKs.
If DEVELOPER_DIR is not set, the build script defaults to
/Applications/Xcode.app/Contents/Developer.
KONAN_HOME resolution: The build downloads Kotlin/Native automatically via the
:core:downloadKotlinNativeDistribution task from the main project. If this fails,
check that the main project builds first.
Linux symbol collision at link time: If you see duplicate
AbslInternalGetFileMappingHint errors, the KRPC-540 workaround in
protobuf/build.gradle.kts may need updating. Check that llvm-objcopy is
available (the build searches Konan dependencies, then PATH).
Clean rebuild (projectRoot: native-deps/shims/):
- Run
cleantask - Optionally run
bazel clean --expungevia shell for Bazel cache - Run
:kotlinx-rpc-grpc-core-shim:assembletask
Trending
Quiet since September.about the whole repository
Who's talking about Kotlin/kotlinx-rpc
- bright-room/mindstock“fix(deps): update kotlinx.rpc to v0.10.4”GitHub · Sep 25, 2026
- bright-room/mindstock“fix(deps): update kotlinx.rpc to v0.10.3”GitHub · Jul 10, 2026
- modelix/modelix.editor“fix(deps): update kotlinx.rpc to v0.10.4”GitHub · Jul 6, 2026
- ktorio/ktor-plugin-registry“Bump the all-gradle group with 11 updates”GitHub · Jun 30, 2026
- DerTyp7214/synara-api“chore(deps): bump kotlinx-rpc from 0.10.2 to 0.10.3”GitHub · Jun 27, 2026
The biggest 5 of 16 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 16
Talked about on GitHub (16 times).
On GitHub · 16
- Sep 25, 2026fix(deps): update kotlinx.rpc to v0.10.4 — bright-room/mindstock0 reactions · 1 comment
- Jul 10, 2026fix(deps): update kotlinx.rpc to v0.10.3 — bright-room/mindstock0 reactions
- Jul 6, 2026fix(deps): update kotlinx.rpc to v0.10.4 — modelix/modelix.editor0 reactions · 1 comment
- Jun 30, 2026Bump the all-gradle group with 11 updates — ktorio/ktor-plugin-registry0 reactions
- Jun 27, 2026chore(deps): bump kotlinx-rpc from 0.10.2 to 0.10.3 — DerTyp7214/synara-api0 reactions · 1 comment
11 more on GitHub
- May 3, 2026Add compiler plugin implementation and Kotlin External FIR Support — TBSten/cream0 reactions
- Mar 30, 2026build(deps): bump kotlinx-rpc from 0.10.1 to 0.10.2 — modelix/modelix.editor0 reactions · 5 comments
- Jan 17, 2026chore(deps): bump kotlinx-rpc from 0.10.1 to 0.10.2 — DerTyp7214/synara-api0 reactions · 2 comments
- Dec 20, 2025build(deps): bump org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-client from 0.10.0 to 0.10.1 — DerTyp7214/synara-api0 reactions · 1 comment
- Dec 20, 2025build(deps): bump org.jetbrains.kotlinx:kotlinx-rpc-krpc-ktor-server from 0.10.0 to 0.10.1 — DerTyp7214/synara-api0 reactions · 1 comment
- Jul 3, 2025Update kxrpc tutorial to 0.8.0 — ktorio/ktor-documentation0 reactions · 2 comments
- Jul 3, 2025Update kxrpc to 0.8.0 — ktorio/ktor-plugin-registry0 reactions · 1 comment
- Apr 4, 2025Update kxrpc to 0.6.0 — ktorio/ktor-plugin-registry0 reactions · 1 comment
- Jan 28, 2025Update kxrpc to 0.5.0 — ktorio/ktor-plugin-registry0 reactions
- Jan 7, 2025Migrate cloud-run server to RPC ProtoBuf — ashdavies/playground.ashdavies.dev0 reactions
- May 26, 2024KotlinでRemote Procedure Calls (RPC) を簡単に行えるライブラリkotlinx.rpc — AndroidDagashi/AndroidDagashi0 reactions
In this repository19 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- commit-changesSkill
- file-youtrack-issueSkill
- fix-issueSkill
- gh-stackSkill
- gradle_expertSkill
- interacting_with_project_runtimeSkill
- introspecting_gradle_projectsSkill
- managing_gradle_dependenciesSkill
- researching_gradle_internalsSkill
- run-local-verificationsSkill
- running_gradle_buildsSkill
- running_gradle_testsSkill
- searching_dependency_sourcesSkill
- update-docSkill
- use-develocitySkill
- use-teamcitySkill
- use-youtrackSkill
- verify-compiler-plugin-compatibilitySkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

