second-state / wasmedge-quickjs

A high-performance, secure, extensible, and OCI-complaint JavaScript runtime for WasmEdge.
Apache License 2.0
476 stars 58 forks source link

Can't build the repo #138

Open LijieZhang1998 opened 3 months ago

LijieZhang1998 commented 3 months ago

Hi, when I followed the instruction to build the repo on macOS, I got the error below. I also tried it on ubuntu, and got the similar error. Any idea? Thanks

warning: ring@0.17.7: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
warning: ring@0.17.7: 1 error generated.

error: failed to run custom build command for `ring v0.17.7`

Caused by:
  process didn't exit successfully: `/Users/lijie.zhang/workspace/wasmedge-quickjs/target/release/build/ring-8c84a2733d23ac2b/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RING_PREGENERATE_ASM
  cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_7_
  OPT_LEVEL = Some("3")
  TARGET = Some("wasm32-wasi")
  HOST = Some("aarch64-apple-darwin")
  cargo:rerun-if-env-changed=CC_wasm32-wasi
  CC_wasm32-wasi = None
  cargo:rerun-if-env-changed=CC_wasm32_wasi
  CC_wasm32_wasi = 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("false")
  cargo:rerun-if-env-changed=CFLAGS_wasm32-wasi
  CFLAGS_wasm32-wasi = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_wasi
  CFLAGS_wasm32_wasi = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-I" "include" "-I" "/Users/lijie.zhang/workspace/wasmedge-quickjs/target/wasm32-wasi/release/build/ring-d092a42e950bbee1/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-nostdlibinc" "-DNDEBUG" "-DRING_CORE_NOSTDLIBINC=1" "-o" "/Users/lijie.zhang/workspace/wasmedge-quickjs/target/wasm32-wasi/release/build/ring-d092a42e950bbee1/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'

  cargo:warning=1 error generated.

  exit status: 1

  --- stderr

  error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-wasi" "-I" "include" "-I" "/Users/lijie.zhang/workspace/wasmedge-quickjs/target/wasm32-wasi/release/build/ring-d092a42e950bbee1/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-pedantic" "-Wall" "-Wextra" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-g3" "-nostdlibinc" "-DNDEBUG" "-DRING_CORE_NOSTDLIBINC=1" "-o" "/Users/lijie.zhang/workspace/wasmedge-quickjs/target/wasm32-wasi/release/build/ring-d092a42e950bbee1/out/crypto/curve25519/curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args "clang" did not execute successfully (status code exit status: 1).

I tried to add the target "wasm32-unknown-wasi" to rust by rustup target add wasm32-unknown-wasi. I got another error:


error: toolchain 'stable-aarch64-apple-darwin' does not support target 'wasm32-unknown-wasi'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
hiroshi commented 2 months ago

On my apple silicon mac, a build with docker works for me. Give it a try. docker run --rm -v$PWD:/wasmedge-quickjs -w/wasmedge-quickjs -ti rust bash

 rustup target add wasm32-wasi
 apt-get update && apt-get install clang
 cargo build --target wasm32-wasi --release

from https://github.com/WasmEdge/docs/pull/236#issuecomment-2183716444

L-jasmine commented 2 months ago

Regarding the issue of compiling on macOS, this is a problem with ring and Rust. To put it simply, the solution is to download wasi-sdk and then use the clang included in wasi-sdk for compilation.

export CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
cargo build --target wasm32-wasi --release