Add musl static lib#214
Conversation
WalkthroughAdds a size-optimized Cargo profile, introduces a musl target with static CRT feature, updates Makefile to build kos-mobile with the new profile for musl, simplifies CI by removing Go binding build/commit steps, adjusts Go demo toolchain and dependency, and disables default features and pins versions in kos-mobile dependencies. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant Make as Makefile
participant Cargo as Cargo (Rust)
participant UFG as uniffi-bindgen-go
participant Out as packages/kos-go
Dev->>Make: make build-go-musl
Make->>Cargo: cargo build --profile min-size --target x86_64-unknown-linux-musl -p kos-mobile
Note right of Cargo: Produces libkos_mobile.a<br/>in .../min-size/
Cargo-->>Make: artifact path
Make->>UFG: generate using lib.../min-size/libkos_mobile.a
UFG-->>Out: Go bindings in ./packages/kos-go
sequenceDiagram
autonumber
participant GH as GitHub Actions
participant Job as kos-go workflow
participant Go as Go toolchain
GH->>Job: Start Linux/macOS jobs
Job->>Go: Run Go tests
Note over Job,Go: Binding build/copy/commit steps removed
Go-->>Job: Test results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.cargo/config.toml (1)
16-19: Ensure MUSL linker is available in CI and dev images.cargo/config.toml (lines 16–19) specifies x86_64-linux-musl-gcc as the linker, but that binary isn’t present; update your CI/dev images to install a musl cross-compiler package (e.g. musl-cross or musl-dev) or add a symlink from musl-gcc to x86_64-linux-musl-gcc.
🧹 Nitpick comments (3)
packages/kos-mobile/Cargo.toml (2)
30-31: Pin + default-features=false may break std usage; explicitly enable std features.anyhow and bigdecimal default to std; disabling default features without enabling std/alloc can cause build/link issues. Suggest enabling std explicitly to keep behavior predictable.
Apply this diff:
- num-bigint = { version = "0.4", default-features = false } - num-traits = { version = "0.2", default-features = false } + num-bigint = { version = "0.4", default-features = false, features = ["std"] } + num-traits = { version = "0.2", default-features = false, features = ["std"] } - anyhow = { version = "1.0.96", default-features = false } + anyhow = { version = "1.0.96", default-features = false, features = ["std"] } - bigdecimal = { version = "0.4.7", default-features = false } + bigdecimal = { version = "0.4.7", default-features = false, features = ["std"] }If you intentionally target no_std, enable alloc appropriately and confirm downstream usage.
Also applies to: 35-35, 37-37
22-23: Centralize version pins in [workspace.dependencies] for consistency.Move these version specs to the root workspace to avoid duplicate versions and make upgrades easier.
Also applies to: 30-31, 35-35, 37-37
Cargo.toml (1)
32-42: Min-size profile: consider thin LTO and validate size trade-offs.
- lto=false can increase size for staticlibs; thin LTO often reduces size with modest compile-time cost.
- opt-level="z" can be smaller than "s" for many crates; measure both.
- overflow-checks=false and panic=abort are fine for FFI, but confirm this matches safety expectations.
If size is critical, build two variants and compare artifacts to confirm the best combo: LTO thin vs off, opt-level z vs s.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (2)
packages/kos-go/demo/go.sumis excluded by!**/*.sumpackages/kos-go/kos_mobile/lib/linux-musl-amd64/libkos_mobile.sois excluded by!**/*.so
📒 Files selected for processing (6)
.cargo/config.toml(1 hunks).github/workflows/kos-go.yaml(0 hunks)Cargo.toml(1 hunks)Makefile(1 hunks)packages/kos-go/demo/go.mod(1 hunks)packages/kos-mobile/Cargo.toml(1 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/kos-go.yaml
🔇 Additional comments (4)
packages/kos-mobile/Cargo.toml (1)
22-23: Disabling default features on core crates: verify no required features are lost.Turning off default-features for kos and kos-codec can drop std/feature-gated code unexpectedly. Ensure all required features are explicitly enabled here or via workspace features.
.cargo/config.toml (1)
2-15: Apple rustflags consolidation looks good.packages/kos-go/demo/go.mod (2)
5-5: Verified submodule tagpackages/kos-go/v0.2.35exists; version will resolve correctly.
3-3: Go 1.24.7 is a valid release—ensure CI and local setups use it
Go 1.24.7 is officially available. Confirm your CI pipelines and developer machines are configured to use Go 1.24.7 to avoid build failures.
| # cargo build --release --target x86_64-unknown-linux-musl --package kos-mobile && \ | ||
| cargo build --profile min-size --target x86_64-unknown-linux-musl --package kos-mobile && \ | ||
| uniffi-bindgen-go --library target/x86_64-unknown-linux-musl/min-size/libkos_mobile.a --out-dir ./packages/kos-go |
There was a problem hiding this comment.
🧩 Analysis chain
Go/musl build: verify toolchain + uniffi version compatibility.
- Ensure musl GCC is present; otherwise this target fails.
- uniffi-bindgen-go tag v0.4.0+v0.28.3 should match workspace uniffi (0.28.1). Minor mismatches can break codegen; confirm compatibility.
If mismatched, align uniffi crate and bindgen versions to the same 0.28.x patch.
🏁 Script executed:
#!/bin/bash
# Check musl toolchain
command -v x86_64-linux-musl-gcc || echo "Missing: x86_64-linux-musl-gcc"
# Confirm uniffi version alignment
rg -nP '^\s*uniffi\s*=\s*\{[^}]*version\s*=\s*"([^"]+)"' Cargo.toml -n -C0
echo "Using uniffi-bindgen-go tag: v0.4.0+v0.28.3"Length of output: 109
Install musl GCC and align uniffi versions
- Install
x86_64-linux-musl-gcc(musl-GCC) so thex86_64-unknown-linux-muslbuild target in the Makefile succeeds. - Sync the
unifficrate version (0.28.1) with theuniffi-bindgen-gotag (v0.4.0+v0.28.3): either bump the crate to 0.28.3 or pin bindgen to 0.28.1 to avoid codegen breaks.
🤖 Prompt for AI Agents
In Makefile around lines 52 to 54, the musl cross-compiler and uniffi version
mismatch cause the x86_64-unknown-linux-musl build and uniffi codegen to fail;
install the musl GCC toolchain (package providing x86_64-linux-musl-gcc) on
CI/dev machines and document it in the Makefile/README so the cargo target
builds succeed, and resolve the uniffi version skew by either bumping the uniffi
crate to 0.28.3 to match bindgen (v0.4.0+v0.28.3) or pin the uniffi-bindgen-go
tool to the older 0.28.1-compatible tag; update Cargo.toml or the tool
installation step in the repo accordingly and ensure the Makefile/build scripts
reference the chosen, consistent versions.
Summary by CodeRabbit
New Features
Improvements
Chores