-
Notifications
You must be signed in to change notification settings - Fork 715
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
Build for wasm #1483
Comments
I'm successfully using ring within a JavaScript-enabled WASM runtime (on the browser, specifically). You might consider trying something like this:
|
Yes, if I only use ECDSA-related functions of ring, it can compile and run on the browser, but once I use Ed25519 related functions, I will get an error. The code is as follows:
|
i have successful build my application with ring from last main git for wasm on macos LLVM_PATH=/opt/homebrew/opt/llvm/
RUSTC_WRAPPER="" \
\
CC_wasm32_unknown_unknown=${LLVM_PATH:?}/bin/clang \
CXX_wasm32_unknown_unknown=${LLVM_PATH:?}/bin/clang++ \
AS_wasm32_unknown_unknown=${LLVM_PATH:?}/bin/llvm-as \
AR_wasm32_unknown_unknown=${LLVM_PATH:?}/bin/llvm-ar \
STRIP_wasm32_unknown_unknown=${LLVM_PATH:?}/bin/llvm-strip \
\
wasm-pack build \
--out-dir "${output_path:?}" \
--target web \
--release need to comment Line 82 in 0f3bf00
Line 39 in 0f3bf00
Line 19 in 0f3bf00
Line 232 in 0f3bf00
|
Has anyone here encountered or had to work around issues with I can successfully build but then my environment complains about things like Do I need to try to build things differently to fix that? I tried the env vars @chertov suggested that failed for me: (Click to expand)error: failed to run custom build command for `ring v0.17.0-not-released-yet (/Users/py/projects/briansmith/ring/codebase-labs/wasm32-unknown-unknown)` Caused by: process didn't exit successfully: `/private/tmp/nix-build-rust-workspace-deps-unknown.drv-1/dummy-src/target/release/build/ring-7aedbc6fa20be512/build-script-build` (exit status: 101) --- stdout cargo:rerun-if-env-changed=RING_PREGENERATE_ASM cargo:rustc-env=RING_CORE_PREFIX=ring_core_0_17_0_not_released_yet_ OPT_LEVEL = Some("z") TARGET = Some("wasm32-unknown-unknown") HOST = Some("aarch64-apple-darwin") CC_wasm32-unknown-unknown = None CC_wasm32_unknown_unknown = Some("clang") CFLAGS_wasm32-unknown-unknown = None CFLAGS_wasm32_unknown_unknown = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None DEBUG = Some("false") --- stderr running "clang" "-Oz" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "include" "-I" "/private/tmp/nix-build-rust-workspace-deps-unknown.drv-1/dummy-src/target/wasm32-unknown-unknown/release/build/ring-e9d9bfabc386e4cd/out" "-Wall" "-Wextra" "-std=c1x" "-Wbad-function-cast" "-Wnested-externs" "-Wstrict-prototypes" "-pedantic" "-pedantic-errors" "-Wall" "-Wextra" "-Wcast-align" "-Wcast-qual" "-Wconversion" "-Wenum-compare" "-Wfloat-equal" "-Wformat=2" "-Winline" "-Winvalid-pch" "-Wmissing-field-initializers" "-Wmissing-include-dirs" "-Wredundant-decls" "-Wshadow" "-Wsign-compare" "-Wsign-conversion" "-Wundef" "-Wuninitialized" "-Wwrite-strings" "-fno-strict-aliasing" "-fvisibility=hidden" "-g3" "-nostdlibinc" "-DNDEBUG" "-DRING_CORE_NOSTDLIBINC=1" "-Werror" "-c" "-o/private/tmp/nix-build-rust-workspace-deps-unknown.drv-1/dummy-src/target/wasm32-unknown-unknown/release/build/ring-e9d9bfabc386e4cd/out/curve25519.o" "crypto/curve25519/curve25519.c" clang-11: error: argument unused during compilation: '-mmacos-version-min=11.0' [-Werror,-Wunused-command-line-argument] clang-11: error: argument unused during compilation: '-nostdlibinc' [-Werror,-Wunused-command-line-argument] clang-11: error: argument unused during compilation: '-arch arm64' [-Werror,-Wunused-command-line-argument] thread 'main' panicked at 'execution failed', /Users/py/projects/briansmith/ring/codebase-labs/wasm32-unknown-unknown/build.rs:707:9 stack backtrace: 0: rust_begin_unwind at /rustc/e0944922007e1bb4fe59809293acf4364410cccc/library/std/src/panicking.rs:584:5 1: core::panicking::panic_fmt at /rustc/e0944922007e1bb4fe59809293acf4364410cccc/library/core/src/panicking.rs:142:14 2: build_script_build::run_command 3: build_script_build::compile 4: build_script_build::build_library::{{closure}} 5: core::iter::adapters::map::map_fold::{{closure}} 6: core::iter::traits::iterator::Iterator::fold 7: as core::iter::traits::iterator::Iterator>::fold 8: as core::iter::traits::iterator::Iterator>::fold 9: core::iter::traits::iterator::Iterator::for_each 10: as alloc::vec::spec_extend::SpecExtend>::spec_extend 11: as alloc::vec::spec_from_iter_nested::SpecFromIterNested>::from_iter 12: as alloc::vec::spec_from_iter::SpecFromIter>::from_iter 13: as core::iter::traits::collect::FromIterator>::from_iter 14: core::iter::traits::iterator::Iterator::collect 15: build_script_build::build_library 16: build_script_build::build_c_code::{{closure}} 17: as core::iter::traits::iterator::Iterator>::for_each 18: build_script_build::build_c_code 19: build_script_build::ring_build_rs_main 20: build_script_build::main 21: core::ops::function::FnOnce::call_once |
@chertov which version of |
Based on the errors there I set
I've gotten stuck on this before and never gotten past it. Instead of all the env vars listed I can set |
@paulyoung hi, my buildscript and clang version function build_wasm() {
LLVM_PATH=/opt/homebrew/opt/llvm/
RUSTFLAGS=--cfg=web_sys_unstable_apis \
RUSTC_WRAPPER="" \
\
CC_wasm32_unknown_unknown=${LLVM_PATH}/bin/clang \
CXX_wasm32_unknown_unknown=${LLVM_PATH}/bin/clang++ \
AS_wasm32_unknown_unknown=${LLVM_PATH}/bin/llvm-as \
AR_wasm32_unknown_unknown=${LLVM_PATH}/bin/llvm-ar \
STRIP_wasm32_unknown_unknown=${LLVM_PATH}/bin/llvm-strip \
\
rustup run stable wasm-pack build \
--out-dir "${output_path:?}" \
--target web \
--release
} /opt/homebrew/opt/llvm/bin/clang --version
Homebrew clang version 14.0.6
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin |
@chertov thanks!
|
…although that seems unrelated to my issue. |
I'm closing this as a duplicate of #918, which is about the same thing: Not all of the ring features are implemented when targeting wasm32 targets. |
Hi, I am using a Nix flake setup with a web application build using At first, I got the same After adding Is there anything additionally to change/add to my setup to make it build again? The same flake setup works flawlessly with |
I'm running into this issue under nix, too. |
I'm also getting this error on Nix with MacOS. Tried adding clang to my flake.nix file, but didn't have any success with this. Edit: I got this working on MacOS with Nix by using the homebrew llvm thanks to @chertov's comment. shellHook = ''
export LLVM_PATH=/usr/local/Cellar/llvm/17.0.6_1
export RUSTC_WRAPPER=""
export CC_wasm32_unknown_unknown=$LLVM_PATH/bin/clang
export CXX_wasm32_unknown_unknown=$LLVM_PATH/bin/clang++
export AS_wasm32_unknown_unknown=$LLVM_PATH/bin/llvm-as
export AR_wasm32_unknown_unknown=$LLVM_PATH/bin/llvm-ar
export STRIP_wasm32_unknown_unknown=$LLVM_PATH/bin/llvm-strip
''; |
My goal is to make the Ring library usable in WASM.
In a simple example, project DEMO relies on Ring and builds project DEMO with wasm-pack, but cannot be used directly in JS. I then used wasm2wat to convert the compiled files and found the following functions is missing.
I discovered that the
GFp_bn_mul_mont
function was written in Perl, But I'm not sure perl is involved.The text was updated successfully, but these errors were encountered: