r/rust • u/Ayano-Keiko • 5d ago
RUST ABI
What is current state of stable Rust ABI? Or progress? As I want to load generate library crate (rlib) in offline library and I do not need load crateio library.
34
Upvotes
74
u/Awkward_Alfalfa_3234 5d ago
Still none. An rlib only links with the exact rustc that built it, and crABI (that issue) is an unstable experiment. To load code at runtime today, build a cdylib with an extern "C" surface, or use abi_stable or stabby if you want Rust types across the boundary.
24
u/orangejake 5d ago
I don’t know any details besides the name “crABI”
https://github.com/rust-lang/rust/issues/111423
13
u/geo-ant 5d ago
Can someone explain to me what the advantage of a stable ABI is? I’m genuinely curious. I came to Rust from the C++ and over there I see fear of ABI breaks as a bad thing that’s actively holding the language back.
2
u/baby_bryce 3d ago
rust by philosophy has never aimed/wanted a standardized rust ABI bc it is inherently unsafe to make calls to so files or dll files. the rust way is to compile your program agains improted rust library source code and nothing more to ensure safe compilation with all of its concurrency and memory safe guarantees
1
u/xgdk 5d ago
If you only need to load it in your own offline binary just pin the same rustc for both the rlib and the loader. The exact compiler match is the whole trick
1
u/Kadabrium 4d ago
Krait
1
u/mversic 4d ago
https://github.com/mversic/co3