sfackler / rust-openssl

OpenSSL bindings for Rust
1.4k stars 749 forks source link

Web Assembly support #1016

Open zrzka opened 5 years ago

zrzka commented 5 years ago

Is there a way how to add Web Assembly support?

I tried to compile it with wasm-pack and it fails, because libc is empty for the wasm target (see this issue or Does it make sense to support WASM?). And then there's a long list of errors like this one:

  error[E0412]: cannot find type `c_int` in this scope
   --> /Users/robertvojta/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.39/src/aes.rs:3:24
    |
  3 | pub const AES_ENCRYPT: c_int = 1;
    |                        ^^^^^ not found in this scope
  help: possible candidate is found in another module, you can import it into scope
    |
  1 | use std::os::raw::c_int;
    |

Which is because of the empty libc.

Was searching for a while and I've found a script to compile openssl to wasm. So, it's possible.

I wonder, Rust & WASM plays nicely together, we have the wasm-pack, does it make sense to support WASM in this crate, so, I can use it as a dependency in Cargo.toml without any additional hassle? Just thinking aloud ...

sfackler commented 5 years ago

@alexcrichton thoughts? On Fri, Nov 9, 2018 at 4:50 AM Zrzka notifications@github.com wrote:

Is there a way how to add Web Assembly support?

I tried to compile it with wasm-pack and it fails, because libc is empty for the wasm target (see this issue https://github.com/rust-lang/libc/issues/861 or Does it make sense to support WASM? https://github.com/rust-lang/libc/issues/858). And then there's a long list of errors like this one:

error[E0412]: cannot find type c_int in this scope --> /Users/robertvojta/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.39/src/aes.rs:3:24 3 pub const AES_ENCRYPT: c_int = 1; ^^^^^ not found in this scope help: possible candidate is found in another module, you can import it into scope
1 use std::os::raw::c_int;

Which is because of the empty libc.

Was searching for a while and I've found a script https://ip6.li/node/129 to compile openssl to wasm. So, it's possible.

I wonder, Rust & WASM plays nicely together, we have the wasm-pack, does it make sense to support WASM in this crate, so, I can use it as a dependency in Cargo.toml without any additional hassle? Just thinking aloud ...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-openssl/issues/1016, or mute the thread https://github.com/notifications/unsubscribe-auth/ABY2UQk1YcefYYf7n3gwt71tOIc7zKbJks5utXoxgaJpZM4YWhkI .

alexcrichton commented 5 years ago

Unfortunately the fact that libc is a blank crate is sort of the least of the worries here. To be clear this likely has a path forward to working with the {asmjs,wasm32}-unknown-emscripten targets one way or another, but I'll be referring to wasm32-unknown-unknown from here on.

For the wasm target it's still an open question how Rust and C code interoperate. Only very very new Clang compilers have support for the wasm32-unknown-unknown target, and even then it's very difficult to get a "sysroot" which actually has header files and such for the wasm target. As a result it's very much not easy to get C code working with wasm32-unknown-unknown today. It's something that we want to empower eventually, but it's tied up in larger questions about how C will use the wasm32-unknown-unknown target idiomatically at all.

For the time being the openssl crate can't really add support for the wasm32-unknown-unknown target without what'll likely be heroics.

zrzka commented 5 years ago

Thanks for the reply! I asked because I'm working on a crate, which is written in Rust and should be usable as a Rust crate, node module and also in the browser via wasm. And it just happened that I need some openssl functionality like cert generation, ecs, ... Will have to think about it more :)

alexcrichton commented 5 years ago

For now we'd recommend using all-rust solutions (if they exist) for the wasm32-unknown-unknown case, but as the C story for wasm32-unknown-unknown matures we'll be able to interoperate!

zrzka commented 5 years ago

Yeah, bleeding edge technologies problems = was expecting this ;) I have to figure out another way.

Thanks again! Feel free to close this issue, I'm happy with these answers.

mankinskin commented 4 years ago

Any solutions to this issue so far?

sdykae commented 3 years ago

up

Jonas-Metzger commented 3 years ago

@alexcrichton I need to "cargo build --target=wasm32-unknown-emscripten" my project with an openssl dependency. You said there might be a way forward?

alexcrichton commented 3 years ago

Sorry I don't have any specific advice here. I've never done this myself but if someone figures it out I'm happy to add support here.

Jonas-Metzger commented 3 years ago

I just learned that someone figured out how to compile openssl to WASM via the wasienv toolchain. If you take a look at their build script, does it look like you could configure cargo to use these options for the wasm32-wasi target? I'd be happy to test the result, but I currently have no idea how I could get cargo to use their configuration when compiling the rust-openssl crate. I just started to learn Rust, and know even less about C/C++ :(

Jonas-Metzger commented 3 years ago

Hi @alexcrichton, I've seen you help with various GitHub issues related to editing .cargo/config.toml to configure cargo build, and you're the most recent contributor to the cargo-wasi repo, so you're definitely the best qualified person to figure out how to build rust-openssl with the wasm32-wasi target.

I found this instruction for setting up the wasm32-wasi target for interop with C. From what I can tell, the goal is to configure the linker and its sysroot to point to an installation of this.

Unfortunately I don't know what a linker or a sysroot is, or how to write a .cargo/config.toml that would carry out those instructions. Is there any chance you could try this out or tell me how to set things up?

I tried this .cargo/config.toml file:

[target.wasm32-wasi]
linker = "/path/to/wasi-sdk-12.0/bin/clang --sysroot=/path/to/wasi-sdk-12.0/share/wasi-sysroot"
rustflags = ["-C", "target-feature=-crt-static"]

But this doesn't fix the compilation error, it still looks like the one below. Not sure what's going on, but it doesn't seem to use the right clang and sysroot :( do you have any idea what to do?

root@Jonas-SB3:/truebit-eth/rust-tool/verify-nitro-attestation# cargo build --target=wasm32-wasi
   Compiling openssl-sys v0.9.65
error: failed to run custom build command for `openssl-sys v0.9.65`

Caused by:
  process didn't exit successfully: `/truebit-eth/rust-tool/verify-nitro-attestation/target/debug/build/openssl-sys-a01c8386e2d88fbd/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=WASM32_WASI_OPENSSL_NO_VENDOR
WASM32_WASI_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
CC_wasm32-wasi = None
CC_wasm32_wasi = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-wasi = None
CFLAGS_wasm32_wasi = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running "perl" "./Configure" "--prefix=/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi"
Configuring OpenSSL version 1.1.1k (0x101010bfL) for gcc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

The library could not be configured for supporting multi-threaded
applications as the compiler options required on this system are not known.
See file INSTALL for details if you need multi-threading.

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
running "make" "depend"
running "make" "build_libs"
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _build_libs
make[1]: Entering directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
make[1]: Leaving directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
make[1]: Entering directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/apps.d.tmp -MT apps/apps.o -c -o apps/apps.o apps/apps.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/bf_prefix.d.tmp -MT apps/bf_prefix.o -c -o apps/bf_prefix.o apps/bf_prefix.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/opt.d.tmp -MT apps/opt.o -c -o apps/opt.o apps/opt.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/s_cb.d.tmp -MT apps/s_cb.o -c -o apps/s_cb.o apps/s_cb.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/s_socket.d.tmp -MT apps/s_socket.o -c -o apps/s_socket.o apps/s_socket.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_cbc.d.tmp -MT crypto/aes/aes_cbc.o -c -o crypto/aes/aes_cbc.o crypto/aes/aes_cbc.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_cfb.d.tmp -MT crypto/aes/aes_cfb.o -c -o crypto/aes/aes_cfb.o crypto/aes/aes_cfb.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_core.d.tmp -MT crypto/aes/aes_core.o -c -o crypto/aes/aes_core.o crypto/aes/aes_core.c
clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_ecb.d.tmp -MT crypto/aes/aes_ecb.o -c -o crypto/aes/aes_ecb.o crypto/aes/aes_ecb.c
Makefile:747: recipe for target 'crypto/aes/aes_core.o' failed
Makefile:755: recipe for target 'crypto/aes/aes_ecb.o' failed
Makefile:696: recipe for target 'apps/bf_prefix.o' failed
Makefile:680: recipe for target 'apps/app_rand.o' failed
Makefile:704: recipe for target 'apps/opt.o' failed
Makefile:720: recipe for target 'apps/s_socket.o' failed
Makefile:688: recipe for target 'apps/apps.o' failed
Makefile:712: recipe for target 'apps/s_cb.o' failed
make[1]: Leaving directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
Makefile:177: recipe for target 'build_libs' failed

--- stderr
In file included from In file included from apps/apps.c:18:
/usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found
apps/app_rand.c:#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
10:
In file included from apps/apps.h:13:
In file included from ./e_os.h:13:
In file included from /usr/lib/clang/6.0.1/include/limits.h:37:
/usr/include/limits.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from apps/s_cb.c:11:
/usr/include/stdio.h:27:In file included from apps/s_socket.c:11:
/usr/include/stdio.h:27:10: fatal errorIn file included from In file included from apps/bf_prefix.c: apps/opt.c::'bits/libc-header-start.h' file not found10
9:
:
/usr/include/stdio.h:In file included from 27apps/apps.h::1013:
:In file included from  ./e_os.h:fatal error13:
: In file included from /usr/lib/clang/6.0.1/include/limits.h:'bits/libc-header-start.h' file not found37
:
/usr/include/limits.h:26:10: fatal error: #include <bits/libc-header-start.h>'bits/libc-header-start.h' file not found

         ^~~~~~~~~~~~~~~~~~~~~~~~~~
10#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
: fatal error: 'bits/libc-header-start.h' file not found
#include <bits/libc-header-start.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from crypto/aes/aes_core.c:39:
In file included from /usr/include/assert.h:35:
/usr/include/features.h:424:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^~~~~~~~~~~~~
1 error generated.
make[1]: *** [crypto/aes/aes_core.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from crypto/aes/aes_ecb.c:10:
In file included from /usr/include/assert.h:35:
/usr/include/features.h:424:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^~~~~~~~~~~~~
1 error generated.
make[1]: *** [crypto/aes/aes_ecb.o] Error 1
1 error generated.
make[1]: *** [apps/bf_prefix.o] Error 1
1 error generated.
make[1]: *** [apps/app_rand.o] Error 1
1 error generated.
make[1]: *** [apps/opt.o] Error 1
1 error generated.
1 error generated.
1 error generated.
make[1]: *** [apps/s_socket.o] Error 1
make[1]: *** [apps/apps.o] Error 1
make[1]: *** [apps/s_cb.o] Error 1
make: *** [build_libs] Error 2
thread 'main' panicked at '

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

    ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.15.0+1.1.1k/src/lib.rs:471:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
Jonas-Metzger commented 3 years ago

I've also tried

env "CC_wasm32-wasi=${WASI_SDK_PATH}/bin/clang" env "CFLAGS_wasm32-wasi=--sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" cargo build --target=wasm32-wasi

which changes the output to

root@Jonas-SB3:/truebit-eth/rust-tool/verify-nitro-attestation# env "CC_wasm32-wasi=${WASI_SDK_PATH}/bin/clang" env "CFLAGS_wasm32-wasi=--sysroot=${WASI_SDK_PATH}/share/wasi-sysroot" cargo build --target=wasm32-wasi
   Compiling openssl-sys v0.9.65
error: failed to run custom build command for `openssl-sys v0.9.65`

Caused by:
  process didn't exit successfully: `/truebit-eth/rust-tool/verify-nitro-attestation/target/debug/build/openssl-sys-a01c8386e2d88fbd/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=WASM32_WASI_OPENSSL_NO_VENDOR
WASM32_WASI_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
CC_wasm32-wasi = Some("/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang")
CFLAGS_wasm32-wasi = Some("--sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot")
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running "perl" "./Configure" "--prefix=/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "--sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot"
Configuring OpenSSL version 1.1.1k (0x101010bfL) for gcc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

The library could not be configured for supporting multi-threaded
applications as the compiler options required on this system are not known.
See file INSTALL for details if you need multi-threading.

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
running "make" "depend"
running "make" "build_libs"
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _build_libs
make[1]: Entering directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
make[1]: Leaving directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
make[1]: Entering directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/apps.d.tmp -MT apps/apps.o -c -o apps/apps.o apps/apps.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/bf_prefix.d.tmp -MT apps/bf_prefix.o -c -o apps/bf_prefix.o apps/bf_prefix.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/opt.d.tmp -MT apps/opt.o -c -o apps/opt.o apps/opt.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/s_cb.d.tmp -MT apps/s_cb.o -c -o apps/s_cb.o apps/s_cb.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF apps/s_socket.d.tmp -MT apps/s_socket.o -c -o apps/s_socket.o apps/s_socket.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_cbc.d.tmp -MT crypto/aes/aes_cbc.o -c -o crypto/aes/aes_cbc.o crypto/aes/aes_cbc.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_cfb.d.tmp -MT crypto/aes/aes_cfb.o -c -o crypto/aes/aes_cfb.o crypto/aes/aes_cfb.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_core.d.tmp -MT crypto/aes/aes_core.o -c -o crypto/aes/aes_core.o crypto/aes/aes_core.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_ecb.d.tmp -MT crypto/aes/aes_ecb.o -c -o crypto/aes/aes_ecb.o crypto/aes/aes_ecb.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG  -MMD -MF crypto/aes/aes_ige.d.tmp -MT crypto/aes/aes_ige.o -c -o crypto/aes/aes_ige.o crypto/aes/aes_ige.c
Makefile:680: recipe for target 'apps/app_rand.o' failed
Makefile:696: recipe for target 'apps/bf_prefix.o' failed
Makefile:704: recipe for target 'apps/opt.o' failed
Makefile:720: recipe for target 'apps/s_socket.o' failed
Makefile:712: recipe for target 'apps/s_cb.o' failed
Makefile:688: recipe for target 'apps/apps.o' failed
make[1]: Leaving directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
Makefile:177: recipe for target 'build_libs' failed

--- stderr
In file included from apps/s_socket.c:15:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
#error "wasm lacks signal support; to enable minimal signal emulation, \
 ^
In file included from apps/s_socket.c:31:
In file included from apps/apps.h:31:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
#error "wasm lacks signal support; to enable minimal signal emulation, \
 ^
In file included from apps/opt.c:9:
In file included from apps/apps.h:31:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:In file included from apps/s_cb.c:14:
In file included from apps/apps.h:31:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
2:2#error "wasm lacks signal support; to enable minimal signal emulation, \: error
 ^
: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
#error "wasm lacks signal support; to enable minimal signal emulation, \
 ^
In file included from apps/app_rand.c:10:
In file included from apps/apps.h:31:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
#error "wasm lacks signal support; to enable minimal signal emulation, \
 ^
In file included from apps/bf_prefix.c:14:
In file included from apps/apps.h:31:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
#error "wasm lacks signal support; to enable minimal signal emulation, \
 ^
1 error generated.
make[1]: *** [apps/app_rand.o] Error 1
make[1]: *** Waiting for unfinished jobs....
1 error generated.
make[1]: *** [apps/bf_prefix.o] Error 1
1 error generated.
make[1]: *** [apps/opt.o] Error 1
In file included from apps/s_socket.c:33:
include/internal/sockets.h:67:12: fatal error: 'netdb.h' file not found
#  include <netdb.h>
           ^~~~~~~~~
3 errors generated.
make[1]: *** [apps/s_socket.o] Error 1
In file included from apps/apps.c:43:
In file included from apps/apps.h:31:
/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot/include/signal.h:2:2: error: "wasm lacks signal support; to enable minimal signal emulation, compile with -D_WASI_EMULATED_SIGNAL and link with -lwasi-emulated-signal"
#error "wasm lacks signal support; to enable minimal signal emulation, \
 ^
1 error generated.
make[1]: *** [apps/s_cb.o] Error 1
1 error generated.
make[1]: *** [apps/apps.o] Error 1
make: *** [build_libs] Error 2
thread 'main' panicked at '

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

    ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.15.0+1.1.1k/src/lib.rs:471:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

If I further try

env "CC_wasm32-wasi=${WASI_SDK_PATH}/bin/clang" env "CFLAGS_wasm32-wasi=--sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -D_WASI_EMULATED_SIGNAL -lwasi-emulated-signal" cargo build --target=wasm32-wasi

I get

root@Jonas-SB3:/truebit-eth/rust-tool/verify-nitro-attestation# env "CC_wasm32-wasi=${WASI_SDK_PATH}/bin/clang" env "CFLAGS_wasm32-wasi=--sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -D_WASI_EMULATED_SIGNAL -lwasi-emulated-signal" cargo build --target=wasm32-wasi
   Compiling openssl-sys v0.9.65
error: failed to run custom build command for `openssl-sys v0.9.65`

Caused by:
  process didn't exit successfully: `/truebit-eth/rust-tool/verify-nitro-attestation/target/debug/build/openssl-sys-a01c8386e2d88fbd/build-script-main` (exit code: 101)
--- stdout
cargo:rustc-cfg=const_fn
cargo:rerun-if-env-changed=WASM32_WASI_OPENSSL_NO_VENDOR
WASM32_WASI_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
CC_wasm32-wasi = Some("/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang")
CFLAGS_wasm32-wasi = Some("--sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -D_WASI_EMULATED_SIGNAL -lwasi-emulated-signal")
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("true")
running "perl" "./Configure" "--prefix=/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install" "no-dso" "no-shared" "no-ssl3" "no-unit-test" "no-comp" "no-zlib" "no-zlib-dynamic" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "gcc" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "--sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot" "-D_WASI_EMULATED_SIGNAL" "-lwasi-emulated-signal"
Configuring OpenSSL version 1.1.1k (0x101010bfL) for gcc
Using os-specific seed configuration
Creating configdata.pm
Creating Makefile

The library could not be configured for supporting multi-threaded
applications as the compiler options required on this system are not known.
See file INSTALL for details if you need multi-threading.

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL file first)         ***
***                                                                ***
**********************************************************************
running "make" "depend"
running "make" "build_libs"
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
/usr/bin/perl "-I." -Mconfigdata "util/dofile.pl" \
    "-oMakefile" include/openssl/opensslconf.h.in > include/openssl/opensslconf.h
make depend && make _build_libs
make[1]: Entering directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
make[1]: Leaving directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
make[1]: Entering directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF apps/app_rand.d.tmp -MT apps/app_rand.o -c -o apps/app_rand.o apps/app_rand.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF apps/apps.d.tmp -MT apps/apps.o -c -o apps/apps.o apps/apps.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF apps/bf_prefix.d.tmp -MT apps/bf_prefix.o -c -o apps/bf_prefix.o apps/bf_prefix.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF apps/opt.d.tmp -MT apps/opt.o -c -o apps/opt.o apps/opt.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF apps/s_cb.d.tmp -MT apps/s_cb.o -c -o apps/s_cb.o apps/s_cb.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF apps/s_socket.d.tmp -MT apps/s_socket.o -c -o apps/s_socket.o apps/s_socket.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF crypto/aes/aes_cbc.d.tmp -MT crypto/aes/aes_cbc.o -c -o crypto/aes/aes_cbc.o crypto/aes/aes_cbc.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF crypto/aes/aes_cfb.d.tmp -MT crypto/aes/aes_cfb.o -c -o crypto/aes/aes_cfb.o crypto/aes/aes_cfb.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF crypto/aes/aes_core.d.tmp -MT crypto/aes/aes_core.o -c -o crypto/aes/aes_core.o crypto/aes/aes_core.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF crypto/aes/aes_ecb.d.tmp -MT crypto/aes/aes_ecb.o -c -o crypto/aes/aes_ecb.o crypto/aes/aes_ecb.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF crypto/aes/aes_ige.d.tmp -MT crypto/aes/aes_ige.o -c -o crypto/aes/aes_ige.o crypto/aes/aes_ige.c
/truebit-eth/rust-tool/wasi-sdk-12.0/bin/clang  -I. -Iinclude -Wa,--noexecstack -Qunused-arguments -O3 -O2 -ffunction-sections -fdata-sections -fPIC -g -fno-omit-frame-pointer --target=wasm32-wasi --sysroot=/truebit-eth/rust-tool/wasi-sdk-12.0/share/wasi-sysroot -DOPENSSLDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/ssl\"" -DENGINESDIR="\"/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/install/lib/engines-1.1\"" -DNDEBUG -D_WASI_EMULATED_SIGNAL -MMD -MF crypto/aes/aes_misc.d.tmp -MT crypto/aes/aes_misc.o -c -o crypto/aes/aes_misc.o crypto/aes/aes_misc.c
Makefile:720: recipe for target 'apps/s_socket.o' failed
make[1]: Leaving directory '/truebit-eth/rust-tool/verify-nitro-attestation/target/wasm32-wasi/debug/build/openssl-sys-b332329b9d65e5f3/out/openssl-build/build/src'
Makefile:177: recipe for target 'build_libs' failed

--- stderr
In file included from apps/s_socket.c:33:
include/internal/sockets.h:67:12: fatal error: 'netdb.h' file not found
#  include <netdb.h>
           ^~~~~~~~~
1 error generated.
make[1]: *** [apps/s_socket.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [build_libs] Error 2
thread 'main' panicked at '

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

    ', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.15.0+1.1.1k/src/lib.rs:471:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
alexcrichton commented 3 years ago

It looks like you figured out how to compile with the right flags, so you're at the point I could possibly reach. That looks like something in OpenSSL is trying to include netdb.h which isn't available on wasm32-wasi. One fix is to fix the code to not include it. Another fix is to update wasi-libc to define it. I don't know which is correct.

Jonas-Metzger commented 3 years ago

I'm getting there @alexcrichton ! But I need your help. I am able to successfully compile using:

#wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
#tar xvf wasi-sdk-12.0-linux.tar.gz
export WASI_SDK_PATH=$PWD/wasi-sdk-12.0
export CFLAGS="${CFLAGS} -D_WASI_EMULATED_SIGNAL -DOPENSSL_NO_SOCK -DOPENSSL_STATIC -DOPENSSL_NO_AFALGENG  -DOPENSSL_SYS_NETWARE"
export CFLAGS="${CFLAGS} -DNO_SYSLOG -DOPENSSL_NO_UI_CONSOLE -DOPENSSL_NO_DGRAM -D_WASI_EMULATED_MMAN -DOPENSSL_NO_SECURE_MEMORY"
CC_wasm32_wasi=$WASI_SDK_PATH/bin/clang CFLAGS=$CFLAGS cargo build --target=wasm32-wasi

However, I still get import errors when trying to run the resulting .wasm file using wasmer or wasmtime. I think I need to set the no-threads and no-shared options from here:

https://wiki.openssl.org/index.php/Compilation_and_Installation#Configure_Options

How do I do that? So far, only the -D<variable> options worked as CFLAGS.

alexcrichton commented 3 years ago

I think that may depend on the errors you're getting as to what the fix is. If the solution is to pass those two options to the configure script, are you building OpenSSL yourself or relying on something like openssl-src? For the latter you'll probably want to work with [patch] while working on this.

Jonas-Metzger commented 2 years ago

@alexcrichton I'm relying on openssl-src, I would have no idea how to build it myself. Could you tell me how to use [patch] (I assume inside openssl-src's Cargo.toml?) to basically do the same as if I passed no-threads and no-shared to the configure script?

alexcrichton commented 2 years ago

Oh for learning about [patch] I'd recommend reading cargo's documentation.

Jonas-Metzger commented 2 years ago

@alexcrichton I checked that out ofc, but it only mentions replacing dependencies, not modifying their build config. Are you suggesting I should clone and modify openssl-src and then use [patch] to point cargo to my modified openssl-src? In that case, could help me find the openssl-src code section that specifies the build config options? I didnt find it. Thanks a lot!

alexcrichton commented 2 years ago

Sorry I don't have the time right now to walk you through editing sources of upstream dependencies. I can try to offer help but this is all best-effort on my part.

cryptoJLee commented 2 years ago

So can we use openssl for wasm or not?

yihuang commented 2 years ago

I just successfully built wasm32-wasi with openssl-src-rs v300, features vendored,

zavalyshyn commented 2 years ago

@yihuang could you please provide some details on how you managed to do that?

zavalyshyn commented 2 years ago

Meanwhile I continued on what @Jonas-Metzger has started. I also try to build a rust project that has rust-openssl as dependency. The target is wasm32-wasi.

I'm currently using the following script

export WASI_VERSION=14
export WASI_VERSION_FULL=${WASI_VERSION}.0
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
tar xvf wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz
export WASI_SDK_PATH=`pwd`/wasi-sdk-${WASI_VERSION_FULL}
CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
export CFLAGS="${CFLAGS} -D_WASI_EMULATED_SIGNAL -DOPENSSL_NO_SOCK -DOPENSSL_STATIC -DOPENSSL_NO_AFALGENG  -DOPENSSL_SYS_NETWARE -D_WASI_EMULATED_PROCESS_CLOCKS -lwasi-emulated-process-clocks"
export CFLAGS="${CFLAGS} -DNO_SYSLOG -DOPENSSL_NO_UI_CONSOLE -DOPENSSL_NO_DGRAM -D_WASI_EMULATED_MMAN -DOPENSSL_NO_SECURE_MEMORY"
CC_wasm32_wasi=$WASI_SDK_PATH/bin/clang CFLAGS=$CFLAGS cargo build --target=wasm32-wasi

I had to add -D_WASI_EMULATED_PROCESS_CLOCKS flag as wasi-sdk suggested, however now I get errors when building crypto/bio/ openssl's dependency.

Any suggestions on how to proceed are very welcome.

Here is an error log:

--- stderr
  crypto/bio/bss_dgram.c:107:14: error: field has incomplete type 'BIO_ADDR' (aka 'union bio_addr_st')
      BIO_ADDR peer;
               ^
  include/openssl/bio.h:174:15: note: forward declaration of 'union bio_addr_st'
  typedef union bio_addr_st BIO_ADDR;
                ^
  crypto/bio/bss_dgram.c:188:13: warning: implicit declaration of function 'BIO_closesocket' is invalid in C99 [-Wimplicit-function-declaration]
              BIO_closesocket(a->num);
              ^
  crypto/bio/bss_dgram.c:307:14: error: variable has incomplete type 'BIO_ADDR' (aka 'union bio_addr_st')
      BIO_ADDR peer;
               ^
  include/openssl/bio.h:174:15: note: forward declaration of 'union bio_addr_st'
  typedef union bio_addr_st BIO_ADDR;
                ^
  crypto/bio/bss_dgram.c:308:5: error: unknown type name 'socklen_t'; did you mean 'locale_t'?
      socklen_t len = sizeof(peer);
      ^~~~~~~~~
      locale_t
  /home/zavalyshyn/Documents/phd/smartcare/dev/annanda/mqtt-example/wasi-sdk-14.0/bin/../share/wasi-sysroot/include/bits/alltypes.h:384:34: note: 'locale_t' declared here
  typedef struct __locale_struct * locale_t;
                                   ^
  crypto/bio/bss_dgram.c:315:21: error: use of undeclared identifier 'MSG_PEEK'
              flags = MSG_PEEK;
                      ^
  crypto/bio/bss_dgram.c:316:15: warning: implicit declaration of function 'recvfrom' is invalid in C99 [-Wimplicit-function-declaration]
          ret = recvfrom(b->num, out, outl, flags,
                ^
  crypto/bio/bss_dgram.c:317:24: warning: implicit declaration of function 'BIO_ADDR_sockaddr_noconst' is invalid in C99 [-Wimplicit-function-declaration]
                         BIO_ADDR_sockaddr_noconst(&peer), &len);
                         ^
  crypto/bio/bss_dgram.c:344:23: warning: implicit declaration of function 'BIO_ADDR_sockaddr_size' is invalid in C99 [-Wimplicit-function-declaration]
          int peerlen = BIO_ADDR_sockaddr_size(&data->peer);
                        ^
  crypto/bio/bss_dgram.c:346:15: warning: implicit declaration of function 'sendto' is invalid in C99 [-Wimplicit-function-declaration]
          ret = sendto(b->num, in, inl, 0,
                ^
  crypto/bio/bss_dgram.c:347:22: warning: implicit declaration of function 'BIO_ADDR_sockaddr' is invalid in C99 [-Wimplicit-function-declaration]
                       BIO_ADDR_sockaddr(&data->peer), peerlen);
                       ^
  crypto/bio/bss_dgram.c:364:13: warning: implicit declaration of function 'BIO_ADDR_family' is invalid in C99 [-Wimplicit-function-declaration]
      switch (BIO_ADDR_family(&data->peer)) {
              ^
  crypto/bio/bss_dgram.c:365:10: error: use of undeclared identifier 'AF_INET'
      case AF_INET:
           ^
  crypto/bio/bss_dgram.c:453:9: warning: implicit declaration of function 'BIO_ADDR_make' is invalid in C99 [-Wimplicit-function-declaration]
          BIO_ADDR_make(&data->peer, BIO_ADDR_sockaddr((BIO_ADDR *)ptr));
          ^
  crypto/bio/bss_dgram.c:453:36: warning: implicit declaration of function 'BIO_ADDR_sockaddr' is invalid in C99 [-Wimplicit-function-declaration]
          BIO_ADDR_make(&data->peer, BIO_ADDR_sockaddr((BIO_ADDR *)ptr));
                                     ^
  crypto/bio/bss_dgram.c:538:17: warning: implicit declaration of function 'BIO_ADDR_family' is invalid in C99 [-Wimplicit-function-declaration]
          switch (BIO_ADDR_family(&data->peer)) {
                  ^
  crypto/bio/bss_dgram.c:539:14: error: use of undeclared identifier 'AF_INET'
          case AF_INET:
               ^
  crypto/bio/bss_dgram.c:577:15: warning: implicit declaration of function 'BIO_ADDR_sockaddr_size' is invalid in C99 [-Wimplicit-function-declaration]
          ret = BIO_ADDR_sockaddr_size(&data->peer);
                ^
  crypto/bio/bss_dgram.c:731:14: error: use of undeclared identifier 'AF_INET'
          case AF_INET:
               ^
  11 warnings and 7 errors generated.
  make[1]: *** [Makefile:1530: crypto/bio/bss_dgram.o] Error 1
  make[1]: *** Waiting for unfinished jobs....
  crypto/bio/bss_log.c:45:11: fatal error: 'syslog.h' file not found
  # include <syslog.h>
            ^~~~~~~~~~
  1 error generated.
  make[1]: *** [Makefile:1554: crypto/bio/bss_log.o] Error 1
  make: *** [Makefile:177: build_libs] Error 2
  thread 'main' panicked at '

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

      ', /home/zavalyshyn/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-src-111.20.0+1.1.1o/src/lib.rs:490:13
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
yihuang commented 2 years ago

@yihuang could you please provide some details on how you managed to do that?

I was just just playing around, didn't tested the result, but the build process succeeded.

In a project that use openssl as dependency, I updated the cargo file like this:

diff --git a/Cargo.toml b/Cargo.toml
index 17591e5..c0ccc74 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -18,7 +18,7 @@ travis-ci = { repository = "witnet/vrf-rs", branch = "master" }

 [dependencies]
 failure = "0.1.5"
-openssl = "0.10"
+openssl = { path = "../rust-openssl/openssl", features = ["vendored"] }
 hmac-sha256 = "0.1.2"

 [dev-dependencies]
@@ -26,3 +26,6 @@ clap = "2.32.0"
 hex = "0.3.2"
 serde = { version = "1.0.90", features = ["derive"] }
 serde_json = "1.0.39"
+
+[patch.crates-io]
+openssl-src = { git = "https://github.com/alexcrichton/openssl-src-rs.git" }

update the rust-openssl/Cargo.toml:

diff --git a/openssl-sys/Cargo.toml b/openssl-sys/Cargo.toml
index 8bba02e9..56d79842 100644
--- a/openssl-sys/Cargo.toml
+++ b/openssl-sys/Cargo.toml
@@ -22,7 +22,7 @@ libc = "0.2"
 [build-dependencies]
 bindgen = { version = "0.59.2", optional = true }
 cc = "1.0"
-openssl-src = { version = "111", optional = true }
+openssl-src = { version = "300", optional = true }
 pkg-config = "0.3.9"
 autocfg = "1.0"

And build like this:

cargo build --target wasm32-wasi --release --example cli

I guess the secret is just update to most recent version of openssl-src?

zavalyshyn commented 2 years ago

Thanks @yihuang. I've tried what you suggested and the build for wasm32-wasi target went further but still failed with fatal error when trying to find pthread.h and netdb.h header files. Unfortunately threads are not yet supported by wasi-sdk.

Is there a way to build rust-openssl without a thread support?

dkozma commented 1 year ago

@zavalyshyn FYI, it looks like wasi-sdk recently released experimental threading support. Not sure if this can unblock your experimentation.

TJFJefroy commented 11 months ago

wasm32-wasi-preview1-threads was added to cargo so any news on this?

souravs17031999 commented 2 months ago

@yihuang I tried your changes which you posted but still getting same errors (before even doing changes)

make[1]: Leaving directory '/mnt/git/hello_world/target/wasm32-wasi/release/build/openssl-sys-41b72c70c2fe2a0f/out/openssl-build/build/src'

  --- stderr
  In file included from apps/lib/app_libctx.c:9:
  In file included from apps/include/app_libctx.h:13:
  In file included from include/openssl/types.h:32:
  In file included from In file included from In file included from include/openssl/e_os2.happs/lib/app_params.c:235:
  :/usr/lib/llvm-10/lib/clang/10.0.0/include/inttypes.h:1021:
  :In file included from 15apps/include/apps.h:: 13fatal error:
  : In file included from include/internal/e_os.h'inttypes.h' file not found:
  16:
  In file included from include/openssl/e_os2.h:235:
  /usr/lib/llvm-10/lib/clang/10.0.0/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
  apps/lib/app_provider.c:10:
  #include_next <inttypes.h>In file included from #include_next <inttypes.h>apps/include/apps.h
  :              ^~~~~~~~~~~~13
  :
  In file included from include/internal/e_os.h:16:
  In file included from include/openssl/e_os2.h:235:
  /usr/lib/llvm-10/lib/clang/10.0.0/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found

                ^~~~~~~~~~~~
  apps/lib/apps_ui.capps/lib/app_x509.c::apps/lib/engine.c:1010:#include_next <inttypes.h>10:17:
  10: :              ^~~~~~~~~~~~
  fatal error10 : 'string.h' file not found
  :fatal error : fatal error'string.h' file not found
  : 'string.h' file not found
  #include <string.h>#include <string.h>
           ^~~~~~~~~~
  apps/lib/columns.c:#include <string.h> /* strcmp */
           ^~~~~~~~~~10
  :10: fatal error: 'string.h' file not found

           ^~~~~~~~~~
  #include <string.h>
           ^~~~~~~~~~
  In file included from apps/lib/apps_opt_printf.c:10:
  apps/include/opt.h:12:10: fatal error: 'sys/types.h' file not found
  #include <sys/types.h>
           ^~~~~~~~~~~~~
  In file included from apps/lib/engine_loader.c:17:
  In file included from apps/include/apps.h:13:
  In file included from include/internal/e_os.h:16:
  In file included from include/openssl/e_os2.h:235:
  /usr/lib/llvm-10/lib/clang/10.0.0/include/inttypes.h:21In file included from apps/lib/apps.c::21:
  In file included from include/openssl/engine.h:24:
  In file included from include/openssl/bn.h:20:
  In file included from include/openssl/e_os2.h:235:
  /usr/lib/llvm-10/lib/clang/10.0.0/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
  15: fatal error: #include_next <inttypes.h>'inttypes.h' file not found
                ^~~~~~~~~~~~

  #include_next <inttypes.h>
                ^~~~~~~~~~~~
  In file included from apps/lib/app_rand.c:10:
  In file included from apps/include/apps.h:13:
  In file included from include/internal/e_os.h:16:
  In file included from include/openssl/e_os2.h:235:
  /usr/lib/llvm-10/lib/clang/10.0.0/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
  #include_next <inttypes.h>
                ^~~~~~~~~~~~
  apps/lib/http_server.c:20:10: fatal error: 'ctype.h' file not found
  #include <ctype.h>
           ^~~~~~~~~
  1 error generated.
  make[1]: *** [Makefile:3767: apps/lib/libapps-lib-apps_opt_printf.o] Error 1
  make[1]: *** Waiting for unfinished jobs....
  1 error generated.
  make[1]: *** [Makefile:3775: apps/lib/libapps-lib-apps_ui.o] Error 1
  1 error generated.
  make[1]: *** [Makefile:3791: apps/lib/libapps-lib-engine.o] Error 1
  1 error generated.
  make[1]: *** [Makefile:3743: apps/lib/libapps-lib-app_rand.o] Error 1
  1 error generated.
  1 error generated.
  1 error generated.
  make[1]: *** [Makefile:3735: apps/lib/libapps-lib-app_provider.o] Error 1
  1 error generated.
  1 error generated.
  1 error generated.
  make[1]: *** [Makefile:3751: apps/lib/libapps-lib-app_x509.o] Error 1
  make[1]: *** [Makefile:3727: apps/lib/libapps-lib-app_params.o] Error 1
  make[1]: *** [Makefile:3799: apps/lib/libapps-lib-engine_loader.o] Error 1
  make[1]: *** [Makefile:3719: apps/lib/libapps-lib-app_libctx.o] Error 1
  make[1]: *** [Makefile:3783: apps/lib/libapps-lib-columns.o] Error 1
  1 error generated.
  1 error generated.
  make[1]: *** [Makefile:3815: apps/lib/libapps-lib-http_server.o] Error 1
  make[1]: *** [Makefile:3759: apps/lib/libapps-lib-apps.o] Error 1
  make: *** [Makefile:2268: build_libs] Error 2
  thread 'main' panicked at /home/soukum/.cargo/git/checkouts/openssl-src-rs-2e32af6c1ebd97b1/274732f/src/lib.rs:625:9:

  Error building OpenSSL:
      Command: cd "/mnt/git/hello_world/target/wasm32-wasi/release/build/openssl-sys-41b72c70c2fe2a0f/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" "make" "build_libs"
      Exit status: exit status: 2

can you please post detailed build setup if you have it somewhere ?