rust-lang / wg-cargo-std-aware

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

Build the standard library for an unsupported target #3

Open ehuss opened 5 years ago

ehuss commented 5 years ago

This is a "use case" issue to try to clarify and discuss a use case, and how it will be addressed.

Building a project for a target that is not available in the Rust distribution can be challenging currently. Some use tools like cargo-xbuild or xargo, or forking rust itself. One of the goals of "std-aware Cargo" is to make this process a little easier.

Many use cases for this are for no_std environments, and use .json target specifications to specify the environment.

Cargo already supports .json targets, and most of the work for supporting #2 should enable this for basic usage.

However, from a higher level this use case has some other issues:

elichai commented 5 years ago

Real world example of this use case: https://github.com/baidu/rust-sgx-sdk

This replaces the std using one of two options:

  1. Xargo, which is a bit broken.
  2. GlobalAlloc + Nightly + no_std + Using their std as a "regular" crate.
ids1024 commented 5 years ago

As far as porting std for a new OS, I suppose something like my Minix port is a fairly minimal example of this, since it requires changes to std (and more substantial changes to libc) but doesn't require too much since it uses the Unix backend.

I started with xargo for it, but had too much many problems with that and just ended up invoking cargo directly in my Makefile to build std.

Even something this simple suffers from a reasonable amount of bit rot, since the changes are spread throughout std (and particularly libc) leading to merge conflicts. Also, to keep it building, the compiler has to be pinned to a specific nightly, or it will soon fail to compile with the newer rustc for one reason or another.

I'm not sure there's any easy solution to that though.

PiDelport commented 3 years ago

Here's the Rust SGX SDK's issue for using std-aware Cargo: https://github.com/apache/incubator-teaclave-sgx-sdk/issues/311