briansmith / ring

Safe, fast, small crypto using Rust
Other
3.64k stars 683 forks source link

Build fails on target wasm32-wasi #2057

Closed bitful-pannul closed 1 month ago

bitful-pannul commented 1 month ago

On aarch64 mac M1 with ring = "0.17.8" in Cargo.toml the command:

cargo +nightly build --target wasm32-wasi

fails with the error:

The following warnings were emitted during compilation:

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

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

Caused by:
  process didn't exit successfully: `/Users/korin/mars/ratatouille/target/debug/build/ring-186621826aa04e29/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_8_
  OPT_LEVEL = Some("0")
  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=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  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
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-wasi"'
  cargo:warning=1 error generated.

  --- stderr

  error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-wasi" "-I" "include" "-I" "/Users/korin/mars/ratatouille/target/wasm32-wasi/debug/build/ring-4ae6f2e640ba6120/out" "-Wall" "-Wextra" "-fvisibility=hidden" "-std=c1x" "-Wall" "-Wbad-function-cast" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wnested-externs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wstrict-prototypes" "-Wundef" "-Wuninitialized" "-g3" "-nostdlibinc" "-DNDEBUG" "-DRING_CORE_NOSTDLIBINC=1" "-o" "/Users/korin/mars/ratatouille/target/wasm32-wasi/debug/build/ring-4ae6f2e640ba6120/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args clang did not execute successfully (status code exit status: 1).
briansmith commented 1 month ago

Most likely you are using Apple Clang on a Mac, right? You need to use LLVM clang since Apple clang doesn't support wasm32.

briansmith commented 1 month ago

Closing as a duplicate of #1824. Please reopen if you aren't using Apple Clang.