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

rand_core and no_std builds #259

Closed
dhardy opened this issue Jan 23, 2019 · 9 comments
Closed

rand_core and no_std builds #259

dhardy opened this issue Jan 23, 2019 · 9 comments

Comments

@dhardy
Copy link

dhardy commented Jan 23, 2019

rand_core = "0.3"

Criterion implicitly requires the std feature of rand_core, though doesn't appear to need it. This appears to be breaking builds.

While we may disable this feature by default in the future, you could help users now by disabling default features on rand_core.

@bheisler
Copy link
Owner

Oh, good grief. I really can't do anything without breaking somebody's code.

Right, I'll have to publish an 0.2.9 later to fix this. Thanks for letting me know!

@bheisler
Copy link
Owner

OK, I've committed the change to disable the default features of rand-core. Can you confirm that fixes it, before I publish a new version?

@dhardy
Copy link
Author

dhardy commented Jan 24, 2019

On which branch? I don't see that change on master.

@hdevalence reported the issue — can you test?

In other news, I have a PR to no longer enable std by default, but it won't take affect until people update to version 0.4 (not yet released).

@bheisler
Copy link
Owner

facepalm

My bad, I forgot to push the commit. Try it now.

@hdevalence
Copy link

Hi, thanks for digging into this! I just ran these tests on my machine, so I think that this does fix the problem:

~/c/x25519-dalek (develop|✔) $ cargo build --features="u32_backend nightly" --no-default-features
    Updating crates.io index
   Compiling rand v0.6.4                                                                                                 
error[E0277]: the trait bound `rngs::jitter::TimerError: std::error::Error` is not satisfied                             
   --> /home/hdevalence/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.4/src/rngs/jitter.rs:267:9              
    |                                                                                                                    
267 |         Error::with_cause(ErrorKind::Unavailable,                                                                  
    |         ^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `rngs::jitter::TimerError`          
    |                                                                                                                    
    = note: required because of the requirements on the impl of `core::convert::From<rngs::jitter::TimerError>` for `alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'static)>`
    = note: required because of the requirements on the impl of `core::convert::Into<alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'static)>>` for `rngs::jitter::TimerError`
    = note: required by `rand_core::Error::with_cause`                                                                   
                                                                                                                         
error: aborting due to previous error                                                                                    
                                                                                                                         
For more information about this error, try `rustc --explain E0277`.                                                      
error: Could not compile `rand`.                                                                                         

To learn more, run the command again with --verbose.
~/c/x25519-dalek (develop|✔) $ git stash pop
(snipped)
~/c/x25519-dalek (develop|✚1) $ git diff
diff --git a/Cargo.toml b/Cargo.toml
index 69b3aa0..3924b42 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -46,3 +46,6 @@ std = ["curve25519-dalek/std"]
 nightly = ["curve25519-dalek/nightly", "clear_on_drop/nightly"]
 u64_backend = ["curve25519-dalek/u64_backend"]
 u32_backend = ["curve25519-dalek/u32_backend"]
+
+[patch.crates-io]
+criterion = { git = "https://github.com/bheisler/criterion.rs" }
~/c/x25519-dalek (develop|✚1) $ cargo build --features="u32_backend nightly" --no-default-features
    Updating git repository `https://github.com/bheisler/criterion.rs`
    Finished dev [unoptimized + debuginfo] target(s) in 0.21s                                                            
~/c/x25519-dalek (develop|✚1) $ 

@bheisler
Copy link
Owner

Alright, I've published 0.2.9 with this fix.

@hdevalence
Copy link

Thanks for the help!

@dhardy
Copy link
Author

dhardy commented Jan 25, 2019

Closing?

@dhardy dhardy closed this as completed Jan 25, 2019
@king-11
Copy link

king-11 commented Aug 7, 2023

can criterion still work with no_std build if html_reports isn't required?

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

No branches or pull requests

4 participants