feat: support cross-compilation (tested for 32-bit ARM Linux)#194
Closed
ibrahim-mubarak wants to merge 1 commit into
Closed
feat: support cross-compilation (tested for 32-bit ARM Linux)#194ibrahim-mubarak wants to merge 1 commit into
ibrahim-mubarak wants to merge 1 commit into
Conversation
Three changes needed to build the SDK with a CMake toolchain file for
a foreign target (verified with armv7-unknown-linux-gnueabihf against
an embedded armv8 AArch32 / Cortex-A32 sysroot):
- CMakeLists.txt: honor a RUST_TARGET_TRIPLE already set in the cache
(e.g. by a cross toolchain file) instead of deriving it only for
macOS; cargo then builds livekit-ffi with --target and the imported
liblivekit_ffi.so location follows target/<triple>/.
- CMakeLists.txt: scope the cargo invocation to -p livekit-ffi. The
workspace has no default-members, so a bare 'cargo build' also
builds every example (including GPU-dependent ones) which is wasted
work natively and fails when cross-compiling.
- cmake/protobuf.cmake: when CMAKE_CROSSCOMPILING, don't force
protobuf_BUILD_PROTOC_BINARIES=ON — a cross-compiled protoc cannot
run on the build host. Require a host protoc (matching the vendored
protobuf version) via -DProtobuf_PROTOC_EXECUTABLE instead; it is
also forwarded to the Rust build through ENV{PROTOC}.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L4fDRyTiTphQnidL2Myptq
|
|
Author
|
Closing for now — will resubmit once ready. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the C++ SDK buildable with a CMake cross toolchain file. Verified end-to-end for 32-bit ARM Linux (
armv7-unknown-linux-gnueabihf) targeting an embedded armv8 AArch32 (Cortex-A32, glibc 2.39) sysroot:liblivekit.so+liblivekit_ffi.sobuild, andlivekit::initialize()/shutdown()round-trips through the FFI under qemu-arm.Companion PR (Rust side / libwebrtc arm build): livekit/rust-sdks#1218
Changes
RUST_TARGET_TRIPLE: a cross toolchain file can now set it (cache var), and the cargo build gets--targetplus the importedliblivekit_ffi.sopath followstarget/<triple>/. Previously the triple was only derived on macOS.-p livekit-ffi: the workspace has nodefault-members, so plaincargo buildalso compiled all examples (including wgpu-based ones) — wasted work natively, build failures when cross-compiling.cmake/protobuf.cmakeforce-enabledprotobuf_BUILD_PROTOC_BINARIES, producing a target-arch protoc that cannot run on the build host ("Exec format error" at codegen). WhenCMAKE_CROSSCOMPILING, protoc binaries are now skipped and a host protoc matching the vendored protobuf version must be passed via-DProtobuf_PROTOC_EXECUTABLE(official release binaries work). It is forwarded to the Rust build viaENV{PROTOC}as before.Usage example
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=toolchain-arm.cmake \ -DProtobuf_PROTOC_EXECUTABLE=/path/to/host/protoc # v25.3 cmake --build build(plus the usual cargo cross setup:
rustup target add, linker in.cargo/config.toml, andLK_CUSTOM_WEBRTCpointing at a libwebrtc built withbuild_linux.sh --arch armfrom the rust-sdks PR.)No behavior change for native builds.
🤖 Generated with Claude Code
https://claude.ai/code/session_01L4fDRyTiTphQnidL2Myptq