-
Notifications
You must be signed in to change notification settings - Fork 204
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
Build failure when used in Substrate (which requires no_std) project #221
Comments
Have you read the docs linked in the compilation error message? |
Specifically, you should read https://docs.rs/getrandom/0.2.3/getrandom/#indirect-dependencies |
Does version mentioned in my Cargo.toml and used on other crate needs to be same ? |
Needs to be the same minor version, so just using |
Thanks for all help! My issue is resolved now. Closing this. |
I am hitting this issue again
|
This doesn't seem to be an issue with I would open a bug with whoever maintains the |
I can understand but when I asked this to substrate people they just read "getrandom" in error and ask me to check if it is using |
Ahhhhhh, so I guess substrate is a If JavaScript isn't supported, you likely want to look into a |
See also paritytech/substrate#5547 |
( Generally I'd raise these kind of issues against the substrate repo or reach out on the substrate chat channel: https://matrix.to/#/#substrate-technical:matrix.org - I don't think there's a problem with the getrandom itself.) |
I'm going to close this as it's really an issue which should be raised against the substrate repo. Basically they should either:
// In a user's main.rs
use substrate::substrate_getrandom;
use getrandom::register_custom_getrandom;
register_custom_getrandom!(substrate_getrandom);
My understanding is that any custom implementation for substrate would just always return an error. This seems fine, and it would be fairly simple to implement: // In some substrate crate
use core::num::NonZeroU32;
use getrandom::Error;
pub fn substrate_getrandom(buf: &mut [u8]) -> Result<(), Error> {
let code = NonZeroU32::new(SOME_SUBSTRATE_ERROR_CODE).unwrap();
Err(Error::from(code))
} See https://docs.rs/getrandom/0.2.3/getrandom/macro.register_custom_getrandom.html for more information. |
My code does not use getrandom directly but though some other creates. It compiles fine normally but when used with in Substrate pallet code it gives me following errors.
error: failed to run custom build command for
evercrypt-sys v0.0.8`Caused by:
process didn't exit successfully:
/home/vivek/dev/composable-node-tezos/target/debug/wbuild/node-template-runtime/target/release/build/evercrypt-sys-bf16303d000cf1c6/build-script-build
(exit status: 101)--- stdout
cargo:rerun-if-changed=wrapper.h
cargo:rerun-if-changed=hacl-star
warning: build failed, waiting for other jobs to finish...
error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
--> /home/vivek/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/getrandom-0.2.3/src/lib.rs:219:9
|
219 | / compile_error!("the wasm32-unknown-unknown target is not supported by
220 | | default, you may need to enable the "js" feature.
221 | | For more information see:
222 | | https://docs.rs/getrandom/#webassembly-support");
| |_________________________________________________________________________^
error[E0433]: failed to resolve: use of undeclared crate or module
imp
--> /home/vivek/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/getrandom-0.2.3/src/lib.rs:246:5
|
246 | imp::getrandom_inner(dest)
| ^^^ use of undeclared crate or module
imp
error: aborting due to 2 previous errors`
Please help how to debug this and fix?
The text was updated successfully, but these errors were encountered: