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

Can't build the repo #138

Open
LijieZhang1998 opened this issue May 13, 2024 · 2 comments
Open

Can't build the repo #138

LijieZhang1998 opened this issue May 13, 2024 · 2 comments

Comments

@LijieZhang1998
Copy link

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: [email protected]: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
warning: [email protected]: 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
Copy link

hiroshi commented Jun 22, 2024

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 WasmEdge/docs#236 (comment)

@L-jasmine
Copy link
Collaborator

L-jasmine commented Jun 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants