rust-lang / wg-cargo-std-aware

Repo for working on "std aware cargo"
133 stars 8 forks source link

Support building workspace with separate build-std parameters #57

Closed jschwe closed 4 years ago

jschwe commented 4 years ago

Suppose we have a workspace with crate A, that should build with build-std=core,alloc and crate B with build-std=std,core,alloc, [...]. Additionally crate B links with / depends on crate A. It would be great if there was a way to configure separate build-std parameters for each crate directly in cargo, without resorting to a custom-build script or a RUSTC_WRAPPER.

Motivation

In my case crate A would be a [no_std] (uni-)kernel and crate B some application, that links to the kernel. Currently linking is done via a build-script, but in the long-term I'm hoping it's possible to support such a configuration directly in cargo. There is a similar (open) issue in cargo regarding supporting separate targets for each crate when calling cargo build. The motivation is similar and I suspect implementing a solution would be similar for both issues too.

Ericson2314 commented 4 years ago

I think what you want is #5 --- way to specify the standard library depencies in Cargo.toml like any other dependency. build-std=.* is blatantly non-compositional, and only was included for sake of getting a prototype out there.

Ericson2314 commented 4 years ago

See also https://github.com/rust-lang/wg-cargo-std-aware/issues/51 for what amounts to the build of rustc and the standard library itself hitting this issue.