Should rustc have split outputs?

So today I ran into:

Which shows how a rust based package may reference rustc’s libraries. We split gcc to different outputs, why don’t we do it for Rust? Just curios.

1 Like

Good catch! Yeah, we probably should split out the libs into a different output. I didn’t even know it was possible to dynamically link to Rust’s standard library. Maybe it was just an oversight?

It looks like this will be an issue in any package that uses crate-type = ["dylib"] in it’s Cargo.toml file.

1 Like

Hmm, I’m not sure whether that will bring much benefit, even with lib as a separate output, almost all of it is what the closure size is all about:

$ du -csh /nix/store/1r7l5brzhjjm1lnx04f4gszy1xgjm1gi-rustc-1.45.0/
$ du -csh /nix/store/1r7l5brzhjjm1lnx04f4gszy1xgjm1gi-rustc-1.45.0/lib

A patch upstream might do it though… @kira-bruneau Texlab doesn’t have cargo-type = ["dylib"] in it’s Cargo.toml - . I’m not experienced in Rust at all, do you have any idea whether that’s avoidable?

The issue is that one of its dependencies (html2md) does: Cargo.toml · e4bf2b4b00a34e21958ba4aa466cc977c9e2c2ea · Kanedias / html2md · GitLab

I don’t know of a way to workaround this yet, but I will look into it. html2md also seems to generate a rlib (essentially a static rust library), maybe there is some way to force texlab to use that instead?

@doronbehar Maybe we could just move the standard library into its own output? It’s only about 3.6M:

$ ls -lh /nix/store/1r7l5brzhjjm1lnx04f4gszy1xgjm1gi-rustc-1.45.0/lib/libstd*
-r--r--r-- 1 root root 3.6M Dec 31  1969 /nix/store/1r7l5brzhjjm1lnx04f4gszy1xgjm1gi-rustc-1.45.0/lib/

I personally fear of brakage but you may want to try this out, note the situation is already a bit complicated:

So staticlib is the culprit… I wonder how rude that would be to ask them right here:

Why did they add staticlib.

@doronbehar Why is staticlib the culprit? From what I know, staticlib won’t be used in a Rust build, it’s created so C, C++, etc… can link to the library.

You are probably correct and I probably misunderstood you and the Rust reference - Linkage - The Rust Reference .