build(android): split GPU acceleration into optional features
Both `kon-transcription` and `kon-llm` previously hardcoded their native acceleration features in Cargo.toml — `whisper-rs` with `vulkan`, `llama-cpp-2` with `openmp` + `vulkan`. That worked everywhere desktop ships (Linux/macOS/Windows all have Vulkan via MoltenVK on Mac), but it made an Android build structurally impossible: NDK builds against drivers that vary wildly across SoCs (Adreno OK, Mali patchy, PowerVR worse), and some older devices have no Vulkan at all. Roadmap step 0 from the Android plan: make the GPU acceleration opt-in so a CPU-only target compiles. Reuses the existing pattern that README's "future Windows non-AVX2 build" comment hinted at. - kon-transcription: new `whisper-vulkan` feature gates `whisper-rs/vulkan` via the optional-syntax `whisper-rs?/vulkan`. Default features stay as `["whisper", "whisper-vulkan"]` so desktop is unchanged. - kon-llm: new `gpu-vulkan` and `openmp` features each gate the matching `llama-cpp-2` feature. Default stays `["gpu-vulkan", "openmp"]`. They are independent so an Android Vulkan build can opt into vulkan without openmp (NDK OpenMP linking has known cross-version fragility). CPU-only build invocations: cargo build -p kon-transcription --no-default-features --features whisper cargo build -p kon-llm --no-default-features Verified: all 91 tests in the buildable-in-sandbox crates still pass. The two crates whose Cargo.toml changed (kon-transcription, kon-llm) can't be compiled in this sandbox (ort-sys CDN + cmake-built llama.cpp); CI's Linux/macOS/Windows builders will exercise the default-feature path exactly as before. https://claude.ai/code/session_0189xUb6ie6t9qHkzatGZ9Rb
This commit is contained in:
@@ -6,13 +6,19 @@ description = "Speech-to-text engine wrappers, model management, and inference c
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
# Whisper backend (direct whisper-rs, vulkan-accelerated). Default on —
|
||||
# gating it exists so a future Windows non-AVX2 build, or a cloud-only
|
||||
# ASR configuration, can drop whisper-rs-sys entirely per brief item
|
||||
# #13. Disabling this feature also drops the WhisperRsBackend module
|
||||
# and the load_whisper entry point.
|
||||
default = ["whisper"]
|
||||
# Whisper backend (direct whisper-rs). Default on — gating it exists so
|
||||
# a future Windows non-AVX2 build, or a cloud-only ASR configuration,
|
||||
# can drop whisper-rs-sys entirely per brief item #13. Disabling this
|
||||
# feature also drops the WhisperRsBackend module and the load_whisper
|
||||
# entry point.
|
||||
#
|
||||
# `whisper-vulkan` is a separate feature so a non-Vulkan target (Android
|
||||
# without GPU drivers, a CPU-only Windows build) can pull in whisper-rs
|
||||
# but skip the Vulkan backend. Build CPU-only with:
|
||||
# cargo build -p kon-transcription --no-default-features --features whisper
|
||||
default = ["whisper", "whisper-vulkan"]
|
||||
whisper = ["dep:whisper-rs", "dep:num_cpus"]
|
||||
whisper-vulkan = ["whisper-rs?/vulkan"]
|
||||
|
||||
[dependencies]
|
||||
kon-core = { path = "../core" }
|
||||
@@ -30,8 +36,9 @@ futures-util = "0.3"
|
||||
# Download integrity verification
|
||||
sha2 = "0.10"
|
||||
|
||||
# Gated behind the `whisper` feature (see [features] above).
|
||||
whisper-rs = { version = "0.16", default-features = false, features = ["vulkan"], optional = true }
|
||||
# Gated behind the `whisper` feature (see [features] above). Vulkan is
|
||||
# additive via the `whisper-vulkan` feature so non-GPU targets can drop it.
|
||||
whisper-rs = { version = "0.16", default-features = false, optional = true }
|
||||
|
||||
# Direct whisper-rs backend (WhisperRsBackend): thread pool sizing.
|
||||
# Gated alongside whisper-rs since no other code in this crate needs it.
|
||||
|
||||
Reference in New Issue
Block a user