10 ms·
not a rust programmer. can someone explain why this is in the final binary and not in a shared library?
by mischief6 3y ago
not a rust programmer. can someone explain why this is in the final binary and not in a shared library?
- simonask 3y agoThe Rust compiler statically links everything into a single binary. This can be changed, but is generally discouraged as there are no ABI stability guarantees at this point.
- zozbot234 3y agoYou can use the C ABI if you want something stable, and there are custom crates that will help with translating from the Rust to the C ABI. (This also helps because the resulting shared objects can potentially be FFI'd with from any language, not just Rust. They might as well be plain C libraries as far as anyone is concerned, only with the usual Rust safety requirements.)
- tialaramex 3y agoAlso, even in "the" C ABI provided by Rust out of the box there's a certain amount of "Well, this is probably what your C compiler does here, but there's no requirement" rather than an actual hard ABI document. A lot of the "We're ABI stable" claims in C and C++ are "We daren't change anything or stuff breaks" which isn't so much an ABI as it is paralysis and Rust is confident it doesn't want to do that.
- Vogtinator 3y ago> A lot of the "We're ABI stable" claims in C and C++ are "We daren't change anything or stuff breaks" which isn't so much an ABI as it is paralysis For the C++ standary library maybe, but for pretty much all others which provide ABI compatibility it's a concious and properly followed decision.
- dhruvrajvanshi 3y ago> "We're ABI stable" claims in C and C++ are "We daren't change anything or stuff breaks" which isn't so much an ABI as it is paralysis and Rust is confident it doesn't want to do that. For C++, yes sure, but I thought C usually has a pretty well specified ABI on most platforms, no?
- deleted 3y ago[deleted]
- lifthrasiir 3y agoI think it's true for common enough platforms, but C is available in too many platforms so I'm not sure it's generally true.