Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile 0.7.0 in no_std environment #868

Closed
russellmcc opened this issue Aug 18, 2019 · 9 comments
Closed

Can't compile 0.7.0 in no_std environment #868

russellmcc opened this issue Aug 18, 2019 · 9 comments

Comments

@russellmcc
Copy link

Starting from cargo new rand_test, I added the following line to Cargo.toml: rand = { version = "0.7.0", default-features = false }. Then, replaced main.rs with the following file:

#![no_std]

fn main() {}

Then, I tried to compile it for arm with cargo build --target thumbv7em-none-eabihf.

I expected errors about not including exception handlers/runtime, but instead, I got the following error:

error[E0463]: can't find crate for `std`
 --> /Users/russruss/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/lazy_static-1.3.0/src/inline_lazy.rs:9:1
  |
9 | extern crate std;
  | ^^^^^^^^^^^^^^^^^ can't find crate
  |
  = note: the `thumbv7em-none-eabihf` target may not be installed

Is there a different set of feature-flags I need to disable std support in rand?

@russellmcc
Copy link
Author

The same test with 0.6.0 seems to work great.

@KodrAus
Copy link

KodrAus commented Aug 18, 2019

It looks like somewhere in our dependency graph is a version of lazy-static that isn't disabling its std support.

If you look in your Cargo.lock are you able to tell which dependencies are pulling in lazy-static?

@russellmcc
Copy link
Author

As I mentioned, only rand was directly added to my dependencies. Here's the output of cargo-tree:

└── rand v0.7.0
    ├── libc v0.2.62
    ├── rand_chacha v0.2.1
    │   ├── c2-chacha v0.2.2
    │   │   ├── lazy_static v1.3.0
    │   │   └── ppv-lite86 v0.2.5
    │   └── rand_core v0.5.0
    └── rand_core v0.5.0 (*)
    [dev-dependencies]
    └── rand_hc v0.2.0
        └── rand_core v0.5.0 (*)

So, it looks like c2-chacha might have something to do with it - I'm not sure I know a tool that can dump out which features are enabled in the dependency graph.

@xlc xlc mentioned this issue Aug 19, 2019
@vks
Copy link
Collaborator

vks commented Aug 19, 2019

If you build rand without the std feature, this should propagate to c2-chacha, which should build without lazy-static at all. I'm puzzled why this is not the case.

@vks
Copy link
Collaborator

vks commented Aug 19, 2019

If you run cargo tree --no-default-features on the Rand root, lazy-static does not appear in the dependency chain. However, for a project depending on rand without default features you get the output above. Is this a Cargo bug?

@burdges
Copy link
Contributor

burdges commented Aug 20, 2019

Isn't that the cargo bug where crates wind up with their test features?

@vks
Copy link
Collaborator

vks commented Aug 20, 2019

@burdges You are right, it seems that the dev-dependency rand_hc pulls in std somehow.

@russellmcc
Copy link
Author

Aha; it looks like this is fixed on the master branch. Sorry for the noise! Eagerly awaiting a new release!

@dhardy
Copy link
Member

dhardy commented Aug 22, 2019

Sorry, I have limited access at the moment, but if @vks opens a PR preparing a new release I can do the rest. However maybe we want to deal with some of the other PRs first?

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 a pull request may close this issue.

5 participants