Skip to content

Allow hermit-abi to build without std#103

Merged
bors[bot] merged 1 commit intohermit-os:masterfrom
josephlr:master
Jan 14, 2021
Merged

Allow hermit-abi to build without std#103
bors[bot] merged 1 commit intohermit-os:masterfrom
josephlr:master

Conversation

@josephlr
Copy link
Copy Markdown
Contributor

This makes crates depending on hermit-abi able to build by
just using -Zbuild-std=core instead of needing all of -Zbuild-std.

Also, remove an unnecessary feature that isn't used anywhere.

Signed-off-by: Joe Richey joerichey@google.com

This makes crates depending on hermit-abi able to check their build by
just using `-Zbuild-std=core` instead of needing all of `-Zbuild-std`.

Also, remove an unnecessary feature that isn't used anywhere.

Signed-off-by: Joe Richey <joerichey@google.com>
josephlr added a commit to rust-random/getrandom that referenced this pull request Jan 14, 2021
We can just use secure_rand64, which should allow us to avoid aarch64
issues.

Note we have to build all of libstd to test this, see
  hermit-os/hermit-rs#103
for more information.

Signed-off-by: Joe Richey <joerichey@google.com>
josephlr added a commit to rust-random/getrandom that referenced this pull request Jan 14, 2021
We can just use secure_rand64, which should allow us to avoid aarch64
issues.

Note we have to build all of libstd to test this, see
  hermit-os/hermit-rs#103
for more information.

Signed-off-by: Joe Richey <joerichey@google.com>
Comment thread hermit-abi/src/lib.rs
//! `hermit-abi` is small interface to call functions from the unikernel
//! [RustyHermit](https://github.com/hermitcore/libhermit-rs).

#![cfg_attr(feature = "rustc-dep-of-std", no_std)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fairly sure that this line is needed, since the hermit std library (in the rust compiler) depends on the hermit-abi crate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just removes the cfg_attr so that this crate is always no_std, so things should still work correctly with it being a dep of libstd.

Copy link
Copy Markdown
Contributor

@jschwe jschwe Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK as of now, it is still necessary to have rustc-dep-of-std in dependencies of std library crates.
There is a plan to remove it (rust-lang/wg-cargo-std-aware#51), but the issue is still open.

This issue is to discuss the strategy for removing the rustc-dep-of-std feature and the rust-std-workspace-* packages which allows standard library crates to use crates from crates.io

Copy link
Copy Markdown
Contributor Author

@josephlr josephlr Jan 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is correct, and that feature isn't removed by this PR.

EDIT: All this PR does is remove the gating of no_std based on the rustc-dep-of-std feature. Right now, this crate requires std unless the rustc-dep-of-std feature is enabled, in which case std is not required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sorry, I got confused there for a moment. Thanks for the clarification.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, libc (which is also a dependency of std) is just unconditionally no_std, see: https://github.com/rust-lang/libc/blob/715b50e1555a339d4e474ac4f6ae5a944bc1b180/src/lib.rs#L28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current network support depends on std. libstd doesn't select this feature. But we should make sure that this is not enabled if std is not enabled.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that support is in a different crate, this crate (hermit-abi) is just a facade crate that doesn't depend on any std code or types.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix with another PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that support is in a different crate, this crate (hermit-abi) is just a facade crate that doesn't depend on any std code or types.

Sorry, my mistake. I mixed up hermit-sys and hermit-abi. :-)

@stlankes
Copy link
Copy Markdown
Contributor

bors r+

@bors
Copy link
Copy Markdown
Contributor

bors Bot commented Jan 14, 2021

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants