Announcing the pure-Rust `sha2` crate

This is just a little crate I put together to use in rustup: sha2. This is the exact same code as in rust-crypto, but this crate has no C code at all, so it should build everywhere Rust does. Since Rust uses SHA-256 for hashing its build artifacts I find myself needing this code a lot.

cc @DaGenix these were the build errors I hit with rust-crypto.

1 Like

Can't this be done with a single crate and features?

Yes it can.

Hmm, it looks like I'm seeing two distinct errors:

cc: error: unrecognized command line option '-marm'


src/util_helpers.c:1:0: error: bad value (armv7-a) for -march= switch

rust-crypto doesn't set those options - they are coming from the gcc crate. So, I'm guessing that either the GCC that Travis is using doesn't support those options, or that the gcc crate is omitting some options it shouldn't. I'm not quite sure, but I'd suspect the former. Confusingly, Aarch64 seems fine.

I've been hesitant to support Cargo feature flags to conditionally compile parts of the library - my concern is that it turns into a giant mess of compile time options that make it much harder to understand what is going on. However, compiling C dependencies does seem to be enough of a pain point that I'm strongly considering add a feature flag to optionally disable them and any algorithms that depend on C code.

I've opened Add a feature flag to omit ASM dependencies by DaGenix · Pull Request #364 · DaGenix/rust-crypto · GitHub to add a feature flag that disables anything that requires a C compiler (ie: anything that uses ASM code). Its a bit ugly, but, given the pain compiling C dependencies has caused, probably worth it. I'll think about it / test it some more over the weekend and try to merge it.