top | item 46508110

(no title)

shatsky | 1 month ago

It does support dynamic libs, but virtually all important Rust software seems to be written without any consideration for it.

discuss

order

johncolanduoni|1 month ago

Rust ABI (as opposed to C ABI) dynamic libraries are incredibly fragile with regard to compiler/build environment changes. Trying to actually swap them out between separate builds is pretty much unsupported. So most of the benefits of dynamic libraries (sharing code between different builds, updating an individual dependency) are not achieved.

They’re only really useful if you’re distributing multiple binary executables that share most of the underlying code, and you want to save some disk space in the final install. The standard Rust toolchain builds use them for this purpose last time I checked.

josephg|1 month ago

Yep that’s right. I’ve been working on a game with bevy. The Bevy game engine supports being dynamic linked during development in order to keep compile times down. It works great.

ComputerGuru|1 month ago

People thinking C++ libraries magically solve this ABI issue is the other side of the coin. I’ve filed numerous bugs against packages precompiled libraries but misusing the C abi so that (owned) objects cross the abi barrier and end up causing heap corruption (with a segfault only if you’re lucky) and other much more subtle heisenbugs.

goku12|1 month ago

Rust does support C ABI through cdylib (as opposed to the unstable dylib ABI). This is used widely, especially for FFI. An example of this is Python modules in Rust using PyO3 [1].

[1] https://pyo3.rs/v0.15.1/#using-rust-from-python

undeveloper|1 month ago

the rust abi is explicitly unstable. there are community projects to bring dynamic linking, but it's mostly not worth it.

nottorp|1 month ago

RAM is cheap mmmkay?

Or at least it used to be when they designed the thing…

RealityVoid|1 month ago

Is it a RAM problem though? My understanding is that each process loads the shared library in its own memory space, so it's only a ROM/HDD space problem.

goodpoint|1 month ago

The problem is vulnerable dependencies and having to update hundreds of binaries when a vuln is fixed.