Skip to content

Add build support for Cargo's build-std feature. - #74033

Merged
bors merged 7 commits into
rust-lang:masterfrom
ehuss:std-compile-all-platforms
Jul 17, 2020
Merged

Add build support for Cargo's build-std feature.#74033
bors merged 7 commits into
rust-lang:masterfrom
ehuss:std-compile-all-platforms

Conversation

@ehuss

@ehuss ehuss commented Jul 4, 2020

Copy link
Copy Markdown
Contributor

This makes some changes to the standard library to make it easier to use with Cargo's build-std feature. The primary goal is to make it so that Cargo and its users do not need to know which crates to build and which features to use for every platform.

Conditional cfgs are adjusted so that there is usually a fall-through for unsupported platforms. Additionally, there is a "restricted-std" feature to mark std as unstable when used with build-std on no_std platforms. There is no intent to stabilize this feature for the foreseeable future.

This borrows some of the implementation for wasm which already does what this needs. More code sharing can be done with some other platforms (there is a lot of duplication with cloudabi, hermit, and sgx), but I figure that can be done in a future PR.

There are some small changes to stable behavior in this PR:

  • std::env::consts::ARCH on asmjs now reports "wasm32", to match its actual architecture.
  • Some of the wasm error messages for unsupported features report a slightly different error message so that the code can be reused.

There should otherwise not be any changes to how std is built for distribution via bootstrap.

This does not yet support all platforms when used with build-std.

  • It doesn't work with 16-bit targets (hashbrown does not support that).
  • It does not work with JSON spec targets.
    • In particular, all target triple snooping will need to be replaced with appropriate target option checking.
  • Switching to gimli (std: Switch from libbacktrace to gimli #73441) will make cross-building much easier.
  • There are still a ton of issues on the Cargo side to resolve. A big one is panic strategy support.

Future PRs are intended to address some of these issues.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants