Hi,
I have some questions regarding dynamic rust packaging.
As most of you probably know, Rust supports building a library crate
crate as a shared object (--crate-type dylib). Those objects contain
everything needed to build & link against them but can be shared by
multiple dependents unlike rust's rlibs that are statically linked into
the resulting binary.
Additionally invoking rustc with -C prefer-dynamic links the rust std
dynamically (/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-
<fingerprint>.so) rather than staticly in the resulting binary and thus
its filesize a lot smaller.
I was wondering if this could be used to build rust packages, because
currently all rust crate packages just provide the sourcecode, and
cargo/rustc builds a static binary (only links against glibc).
Additionally devel:languages:rust:crates seems kinda dead (last updated
package seven months ago), but dynamic linking could offer an advantage
over vendoring the dependencies into your package.
The downside to dynamic linking in rust is, that if a library or the
std gets updated but a dependency didn't it'll break the dependency.
However, given that the buildservice will recompile any dependents if a
package gets updated, the only case where this could become an issue is
in case of a partial update.
If anyone wants to experiment with rust's dynamic librarys, heres how I
got it to work:
1. Build any library you depend on with --crate-type dylib
2. Drop the library you've just built from the dependencies section
3. Rebuild the project with RUSTFLAGS="-C prefer-dynamic --extern
depname=../path/to/built/library/libdepname.so" cargo -v build
4. To run the built binary make sure that the libdepname.so is in your
LD search path.
Regards,
Florian "sp1rit"
--
Matrix: @sp1rit:tchncs.de
<sp1rit(a)disroot.org>
D248BF2F4C6A82A1E0569D897D8C1CD573166D09
<sp1rit(a)national.shitposting.agency>
BBDE032EAAFBFC627FB7E635B1F4055D8460CE34