I have a crate that adds bindings for a large C library. Rust bindings to shared library are easy to use. But there are some issues with current solution:
- Binding assumed to link application to a shared library installed at the target computer’s LD_PATH. What if target computer does not have shared libraries support (e.g. an embedded device or custom OS).
- Compiled application is not hermetic. i.e. it requires that users installed additional system packages. Every operation system has its own way to install shared libraries and it complicats installation. What if OS does not have a suitable package? What is user does not have “install additional package” permissions?
- It is hard to control for a user what version of system library is installed. What if a user needs libFoo.2.6 when system provides libFoo.1.2 only?
- Keeping code in a shared library prevents to perform Link-Time-Optimization over whole project.
It would be interesting to see a way to embed a C library into Rust crate and share as one hermetic thing without external dependencies. The C code will be part of the Rust crate and distribute as a whole thing. Then cargo/rustc compile both C and rust into bytecode and process it together.
Is there anything like this possible today?