Skip to content

Enable rlib-only libstd build (no dylib) #56443

Open
@RalfJung

Description

@RalfJung

For cross-building libstd (for use e.g. with miri), it would be great if one could make an rlib-only libstd build. This is because building a dylib invokes the native linker, and that fails when the target architectures is too foreign and/or not supported by the installed C toolchain. (Currently, we build libstd both as rlib and dylib.)

So my goal was to equip libstd with a feature flag to control whether it is built as a dylib (next to the rlib) or not. To this end, I patched collect_crate_types such that the crate types passed on the command-line and the one given as attributes are merged (instead of command-line taking precedence). That means I can use #![cfg_attr(dylib, crate-type = "dylib")] to make a dylib feature enable a dylib build. That seems to work, however, there is a problem: During bootstrap, rustbuild uses cargo's stamp file to determine which files to copy into the sysroot, and that stamp file now no longer includes the libstd.so, breaking the build.

I wonder if there is maybe a better way to achieve an rlib-only libstd build?

Cc @eddyb @alexcrichton any advice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-driverArea: rustc_driver that ties everything together into the `rustc` compilerC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions