alexcrichton / openssl-src-rs

Source code and logic to build OpenSSL from source
Apache License 2.0
68 stars 113 forks source link

How to build for wasm32-wasi? #88

Closed FrankC01 closed 3 years ago

FrankC01 commented 3 years ago

Not sure of the steps to do this?

arthurgreef commented 3 years ago

This is how far we get after cloning repo and submodule.

Set up the include environment variable. export C_INCLUDE_PATH=/usr/include/:/usr/include/x86_64-linux-gnu

Add the following to lib.rs.

.arg("no-ui"); if target.contains("wasi") { configure.arg("no-asm"); configure.arg("no-sock"); configure.arg("no-afalgeng"); } configure.arg("-DOPENSSL_NO_SOCK"); configure.arg("-DOPENSSL_NO_DGRAM"); configure.arg("-DNO_SYSLOG"); // not supposed to be set externally

Run the following command from the root. cargo run --manifest-path ./testcrate/Cargo.toml --target wasm32-wasi --features="package"

We get the following errors.

--- stderr ***** Deprecated options: no-ui apps/apps.c:2707:5: error: invalid output constraint '=c' in asm FD_ZERO(&asyncfds); ^ /usr/include/sys/select.h:88:26: note: expanded from macro 'FD_ZERO'

define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)

                              ^

/usr/include/bits/select.h:37:8: note: expanded from macro '__FD_ZERO' : "=c" (d0), "=D" (d1) \ ^ 1 error generated. make[1]: [Makefile:688: apps/apps.o] Error 1 make[1]: Waiting for unfinished jobs.... make: *** [Makefile:177: build_libs] Error 2 thread 'main' panicked at '

Error building OpenSSL: Command: "make" "build_libs" Exit status: exit code: 2

FrankC01 commented 3 years ago

Able to get it to build with --target wasm32-wasi:

  1. Installed lib6
  2. Installed http://ports.ubuntu.com/pool/universe/w/wasi-libc/wasi-libc_0.0~git20200319.9efc2f4-2_all.deb
  3. Set export C_INCLUDE_PATH=/usr/include/wasm32-wasi:/usr/include/:/usr/include/x86_64-linux-gnu

Set in src/lib.rs

        configure.arg("-DOPENSSL_NO_SOCK");
        configure.arg("-D_WASI_EMULATED_MMAN");
        configure.arg("-DOPENSSL_NO_DGRAM");
        configure.arg("-DNO_SYSLOG");  // not supposed to be set externally