sfackler / rust-openssl

OpenSSL bindings for Rust
1.4k stars 749 forks source link

wasm32-unknown-unknown error with rust-analyzer OpenSSL #2014

Open WarrenN1 opened 1 year ago

WarrenN1 commented 1 year ago

I have tried so many solutions between reinstalling, reinstalling the OS, doing a manual install etc. I am here as a last result and any help would be deeply appreciated.

I am on the CentOS Stream release 8 (Fedora). For my Cargo Build, I have configured Vscode as follows:

{
"rust-analyzer.cargo.target": "wasm32-unknown-unknown"
}

I have also already installed:

sudo yum install openssl openssl-devel

which after being run yields:

> openssl version -d
OPENSSLDIR: "/etc/pki/tls"

Per the guide.

My cargo.toml looks like:

[package]
name = "frontend"
version = "0.1.0"
edition = "2021"

[build]
target = "wasm32-unknown-unknown"
#-------------------------------------------------------------------------------
[[bin]]
name = "frontend-bin"
path = "src/main.rs"
target = "wasm32-unknown-unknown"
#-------------------------------------------------------------------------------
[lib]
name = "frontend"
path = "src/lib.rs"
crate-type = ["cdylib"]
target = "wasm32-unknown-unknown"
#-------------------------------------------------------------------------------
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
#-------------------------------------------------------------------------------
openssl = { version = "0.10", features = ["vendored"] }
[ERROR rust_analyzer::main_loop] FetchBuildDataError:
error: failed to run custom build command for `openssl-sys v0.9.91`

Caused by:
  process didn't exit successfully: `/home/warrenniles/project/target/debug/build/openssl-sys-d97b90dc6423e842/build-script-main` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=WASM32_UNKNOWN_UNKNOWN_OPENSSL_NO_VENDOR
  WASM32_UNKNOWN_UNKNOWN_OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
  OPENSSL_NO_VENDOR unset
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=AR_wasm32-unknown-unknown
  AR_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=AR_wasm32_unknown_unknown
  AR_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_AR
  TARGET_AR = None
  cargo:rerun-if-env-changed=AR
  AR = None
  running: "clang" "-print-search-dirs"
  exit status: 0
  RUSTC_LINKER = None
  cargo:rerun-if-env-changed=CROSS_COMPILE
  CROSS_COMPILE = None
  cargo:rerun-if-env-changed=ARFLAGS_wasm32-unknown-unknown
  ARFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=ARFLAGS_wasm32_unknown_unknown
  ARFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_ARFLAGS
  TARGET_ARFLAGS = None
  cargo:rerun-if-env-changed=ARFLAGS
  ARFLAGS = None
  cargo:rerun-if-env-changed=RANLIB_wasm32-unknown-unknown
  RANLIB_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=RANLIB_wasm32_unknown_unknown
  RANLIB_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_RANLIB
  TARGET_RANLIB = None
  cargo:rerun-if-env-changed=RANLIB
  RANLIB = None
  running: "clang" "-print-search-dirs"
  exit status: 0
  cargo:rerun-if-env-changed=RANLIBFLAGS_wasm32-unknown-unknown
  RANLIBFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=RANLIBFLAGS_wasm32_unknown_unknown
  RANLIBFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_RANLIBFLAGS
  TARGET_RANLIBFLAGS = None
  cargo:rerun-if-env-changed=RANLIBFLAGS
  RANLIBFLAGS = None
  running cd "/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src" && AR="ar" CC="clang" RANLIB="ranlib" "perl" "./Configure" "--prefix=/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/install" "--openssldir=/usr/local/ssl" "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-unknown-unknown"
  Configuring OpenSSL version 1.1.1v (0x1010116fL) 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 cd "/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src" && "make" "depend"
  running cd "/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "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 '/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src'
  make[1]: Leaving directory '/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src'
  make[1]: Entering directory '/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/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-unknown-unknown -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/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-unknown-unknown -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/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-unknown-unknown -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/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-unknown-unknown -DOPENSSLDIR="\"/usr/local/ssl\"" -DENGINESDIR="\"/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/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
  make[1]: Leaving directory '/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src'

  --- stderr
  In file included from apps/app_rand.c:10:
  In file included from apps/apps.h:13:
  In file included from ./e_os.h:16:
  In file included from include/openssl/e_os2.h:243:
  /usr/lib64/clang/14.0.6/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
  #include_next <inttypes.h>
                ^~~~~~~~~~~~
  In file included from apps/opt.c:9:
  In file included from apps/apps.h:13:
  In file included from ./e_os.h:16:
  In file included from include/openssl/e_os2.h:243:
  /usr/lib64/clang/14.0.6/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
  #include_next <inttypes.h>
                ^~~~~~~~~~~~
  apps/bf_prefix.c:10:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  apps/apps.c:18:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  1 error generated.
  make[1]: *** [Makefile:679: apps/app_rand.o] Error 1
  make[1]: *** Waiting for unfinished jobs....
  make[1]: *** [Makefile:695: apps/bf_prefix.o] Error 1
  1 error generated.
  make[1]: *** [Makefile:703: apps/opt.o] Error 1
  1 error generated.
  make[1]: *** [Makefile:687: apps/apps.o] Error 1
  make: *** [Makefile:177: build_libs] Error 2
  thread 'main' panicked at '

  Error building OpenSSL:
      Command: cd "/home/warrenniles/project/target/wasm32-unknown-unknown/debug/build/openssl-sys-7a85783a937b61be/out/openssl-build/build/src" && MAKEFLAGS="-j --jobserver-fds=7,8 --jobserver-auth=7,8" "make" "build_libs"
      Exit status: exit status: 2

      ', /home/warrenniles/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-111.27.0+1.1.1v/src/lib.rs:506:13
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/panicking.rs:593:5
     1: core::panicking::panic_fmt
               at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/panicking.rs:67:14
     2: openssl_src::Build::run_command
               at /home/warrenniles/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-111.27.0+1.1.1v/src/lib.rs:506:13
     3: openssl_src::Build::build
               at /home/warrenniles/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-src-111.27.0+1.1.1v/src/lib.rs:478:13
     4: build_script_main::find_vendored::get_openssl
               at ./build/find_vendored.rs:5:21
     5: build_script_main::find_openssl
               at ./build/main.rs:53:20
     6: build_script_main::main
               at ./build/main.rs:73:35
     7: core::ops::function::FnOnce::call_once
               at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/ops/function.rs:250:5
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
sfackler commented 1 year ago

Installing OpenSSL on Linux is not going to be relevant - that is built for x86_64-linux-gnu or whatever.

I don't believe that OpenSSL supports wasm32-unknown-unknown, or if it does I don't know how to set up a build environment for that.

Skepfyr commented 1 year ago

There's a bunch of discussion over on #1016, note that there are 3 wasm32 targets (unknown, emscripten, wasi) which appear to have had varying degrees of success.