microsoft / regorus

Regorus - A fast, lightweight Rego (OPA policy language) interpreter written in Rust.
MIT License
153 stars 34 forks source link

Failed to build wasm #346

Closed rech closed 2 weeks ago

rech commented 2 weeks ago

Hi, I really like this project looks very promising.

I am trying to build a wasm package using wasm-pack.

but i get an error with ring v0.17.8. Also, it seems like there is no cargo.lock file in the project.

I am running this command: wasm-pack build --target nodejs --release (Actually I would like to use it also in the we with --target web)

And this is the response: [INFO]: 🎯 Checking for the Wasm target.../Users/rechaviaelias/workplace [INFO]: 🌀 Compiling to Wasm... Compiling ring v0.17.8 Compiling url v2.5.3 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-unknown"' 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/some_user/some_folder/regorus/target/release/build/ring-3690a7590a00bf41/build-script-build (exit status: 1) --- stdout cargo:rerun-if-env-changed=RING_PREGENERATE_ASM cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_178 OPT_LEVEL = Some(3) OUT_DIR = Some(/Users/some_user/some_folder/regorus/target/wasm32-unknown-unknown/release/build/ring-dea52e2f959e3e40/out) TARGET = Some(wasm32-unknown-unknown) HOST = Some(aarch64-apple-darwin) 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=CROSS_COMPILE CROSS_COMPILE = None RUSTC_LINKER = None cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT RUSTC_WRAPPER = 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:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"' cargo:warning=1 error generated.

--- stderr

error occurred: Command "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "include" "-I" "/Users/some_user/some_folder/regorus/target/wasm32-unknown-unknown/release/build/ring-dea52e2f959e3e40/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/some_user/some_folder/regorus/target/wasm32-unknown-unknown/release/build/ring-dea52e2f959e3e40/out/fad98b632b8ce3cc-curve25519.o" "-c" "crypto/curve25519/curve25519.c" with args cc did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish... Error: Compiling your crate to WebAssembly failed Caused by: Compiling your crate to WebAssembly failed Caused by: failed to execute cargo build: exited with exit status: 101 full command: cd "/Users/some_user/some_folder/regorus/bindings/wasm" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

what can can I do to fix it?

rech commented 2 weeks ago

solved using docker.

anakrish commented 2 weeks ago

@rech Which platform did you encounter the error on? If Windows, can you try after installing LLVM (Clang). IIRC ring requires clang for build.