Enable build with global context less secure#387
Conversation
We should use `Deref` from `core` since it is available there.
When building with --no-default-features the compiler emits: warning: unused import: `mem` The call site is feature gated so we either need to feature gate the import or use a fully qualified path. Since 'core' is quite short elect to use the fully qualified path.
Currently we cannot build cleanly with `--no-default-features`. The `Debug` implementation for secrets is feature gated on `std` because it uses a hasher from `std`. If `bitcoin_hashes` is enabled we can use it for hashing. If neither `std` nor `bitcoin_hashes` is enabled fall back to outputting: <secret requires std or bitcoin_hashes feature to display>
Currently this command fails: cargo build --no-default-features --features=global-context-less-secure All features should be able to be built individually, this is currently not the case with `global-context-less-secure`. Enable `std` if `global-context-less-secure` is enabled (because `Once` only comes from `std`, not available in `core`). Add `global-context-less-secure` to the features test array in `contrib/test.sh`. With this applied the build command above runs successfully.
| lowmemory = ["secp256k1-sys/lowmemory"] | ||
| global-context = ["std", "rand-std", "global-context-less-secure"] | ||
| global-context-less-secure = [] | ||
| global-context-less-secure = ["std"] |
There was a problem hiding this comment.
I'd rather we actually fix the build rather than depend on std (see conversation at #359 for one way to do this). The reason for global-context-less-secure, in part, is that we want to support global-context without the rand dependency, in part for platforms where we can't use rand. There are some platforms (like wasm, specifically), where we can technically build without no-std, but where we may not actually have an actual std environment to call, relying on LTO to remove the calls that we can't make.
There was a problem hiding this comment.
Cool, I'm off for the next few days. I'll convert this to draft and re-spin when I'm back. Thanks.
There was a problem hiding this comment.
Now I have read that link I think this whole PR should be closed.
Currently the following build command fails:
Debugusingbitcoin_hashes::sha256as the hasher as well as a fallback implementation. Please review carefully.global-context-less-secureto the test features matrix