Stream: t-compiler

Topic: build rlib only version of libstd


Jake Hughes (May 13 2020 at 11:44, on Zulip):

Hi, is it possible to recompile the stdlib to only emit static rlibs? I'm doing some experimental stuff in libstd which borks when linking libstd.so so i'd like to turn it off for the time being. Thanks

bjorn3 (May 13 2020 at 11:58, on Zulip):

@Jake Hughes You can remove the dylib type from crate-type = ["rlib", "dylib"] in libstd/Cargo.toml. You can also completely remove that line, as rlib is the default for libraries.

Jake Hughes (May 13 2020 at 12:04, on Zulip):

Oh perfect. Thanks @bjorn3 ! What's the reason for dylib in here? Is this incase one may want to dynamically link libstd if they use the same rustc version with a compatible abi?I was under the impression that libstd was always statically linked to a rust target.

Jake Hughes (May 13 2020 at 12:05, on Zulip):

are there some parts of the rust ecosystem that rely on having libstd in dylib form?

bjorn3 (May 13 2020 at 12:08, on Zulip):

If any linked crate is a dylib, rustc will use the dylib variant of a crate whenever it is available. You can also use -Cprefer-dynamic to force using the dylib variant of all crates.

mati865 (May 15 2020 at 09:52, on Zulip):

Jake Hughes: are there some parts of the rust ecosystem that rely on having libstd in dylib form?

Testsuite for an example.

Josh Triplett (May 16 2020 at 07:24, on Zulip):

Linux distributions ship std as a .so dynamic library.

RalfJ (May 16 2020 at 11:03, on Zulip):

related issue: https://github.com/rust-lang/rust/issues/56443

Last update: Jun 04 2020 at 17:55UTC