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

Support wasm32-unknown-unknown #33

Open
vivekvpandya opened this issue Jul 16, 2021 · 1 comment
Open

Support wasm32-unknown-unknown #33

vivekvpandya opened this issue Jul 16, 2021 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed wasm

Comments

@vivekvpandya
Copy link

vivekvpandya commented Jul 16, 2021

Using evercrypt with Substrate (no_std and target = wasm32-unknown-unknown)

I am trying to build evercrypt-sys with following change to enable wasm32-unknown-unknown target .

diff --git a/evercrypt-sys/build.rs b/evercrypt-sys/build.rs
index a02144b..88bd25f 100644
--- a/evercrypt-sys/build.rs
+++ b/evercrypt-sys/build.rs
@@ -330,6 +330,9 @@ fn main() {
             .set_hacl_src_dir("msvc-compatible"),
         // TODO: Which Android versions do we want to support?
         "aarch64-linux-android" => panic!("Target '{:?}' is not supported yet.", target),
+        "wasm32-unknown-unknown" => {
+            cfg.set_cross_config_flags(vec!["-target", "wasm32-unknown-unknown"])
+        }
         _ => panic!("Target '{:?}' is not supported yet.", target),
     };

And my build command is: cargo test --target wasm32-unknown-unknown
I am getting following error. (I have glibc-devel package install on my Fedora)

   Compiling evercrypt-sys v0.0.8 (/home/vivek/dev/evercrypt-rust/evercrypt-sys)
error: failed to run custom build command for `evercrypt-sys v0.0.8 (/home/vivek/dev/evercrypt-rust/evercrypt-sys)`
Caused by:
  process didn't exit successfully: `/home/vivek/dev/evercrypt-rust/evercrypt-sys/target/debug/build/evercrypt-sys-5c5394f05cb975ec/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=wrapper.h
  cargo:rerun-if-changed=hacl-star
  build_config: BuildConfig { hacl_src_dir: "gcc-compatible", cross: true, config_flags: ["-target", "wasm32-unknown-unknown"], make_flags: [], env: {}, lib_name: "evercrypt", windows: false }
  out_path: "/home/vivek/dev/evercrypt-rust/evercrypt-sys/target/wasm32-unknown-unknown/debug/build/evercrypt-sys-5b180f46e6e63781/out"
  hacl_src_path: "/home/vivek/dev/evercrypt-rust/evercrypt-sys/target/wasm32-unknown-unknown/debug/build/evercrypt-sys-5b180f46e6e63781/out/hacl-star/dist/gcc-compatible"

  --- stderr
  /home/vivek/dev/evercrypt-rust/evercrypt-sys/target/wasm32-unknown-unknown/debug/build/evercrypt-sys-5b180f46e6e63781/out/hacl-star/dist/gcc-compatible/libintvector.h:4:10: fatal error: 'sys/types.h' file not found
  /home/vivek/dev/evercrypt-rust/evercrypt-sys/target/wasm32-unknown-unknown/debug/build/evercrypt-sys-5b180f46e6e63781/out/hacl-star/dist/gcc-compatible/libintvector.h:4:10: fatal error: 'sys/types.h' file not found, err: true
  thread 'main' panicked at 'Unable to generate bindings: ()', build.rs:272:10
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace```

Please help on this
@franziskuskiefer franziskuskiefer added enhancement New feature or request help wanted Extra attention is needed wasm labels Jul 17, 2021
@franziskuskiefer franziskuskiefer changed the title Using evercrypt with Substrate (no_std and target = wasm32-unknown-unknown) Support wasm32-unknown-unknown Jul 17, 2021
@franziskuskiefer
Copy link
Owner

Thanks for taking a look at evercrypt @vivekvpandya
Currently neither the Rust crate nor hacl* itself supports wasm. hacl* has a separate wasm support (there are JS bindings).
There are two options for supporting wasm

  1. compile the hacl* C to wasm for the Rust wasm target
  2. use the hacl* wasm code generated from kremlin directly in the Rust wasm target

The latter is probably the preferable approach but requires different bindings than evercrypt-sys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed wasm
Projects
None yet
Development

No branches or pull requests

2 participants