We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I tried this code:
#![feature(vec_into_raw_parts)] pub mod rs_aes; pub mod rs_rsa; mod utils; use std::{borrow::Cow, error::Error}; use utils::set_panic_hook; use wasm_bindgen::{prelude::*, JsCast}; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_namespace = WebAssembly, typescript_type = "WebAssembly.Memory")] pub type Memory; #[wasm_bindgen(js_namespace = console)] pub fn log(s: &str); } #[wasm_bindgen] pub fn shared_memory() -> Memory { JsValue::from(wasm_bindgen::memory()).unchecked_into::<Memory>() } #[wasm_bindgen] pub enum Encode { BASE64, HEX, } #[wasm_bindgen] pub struct SharedPtr { pub at_ptr: *mut u8, pub len: usize, pub cap: usize, } impl Drop for SharedPtr { fn drop(&mut self) { std::mem::drop(self); } } impl SharedPtr { fn new(view: Vec<u8>) -> SharedPtr { let (at_ptr, len, cap): (*mut u8, usize, usize) = view.into_raw_parts(); SharedPtr { at_ptr, len, cap } } } #[wasm_bindgen] impl SharedPtr { #[wasm_bindgen(catch)] pub fn with_capacity(capacity: usize) -> SharedPtr { set_panic_hook(); let mut view: Vec<u8> = Vec::<u8>::with_capacity(capacity); unsafe { view.set_len(capacity); } SharedPtr::new(view) } #[wasm_bindgen(catch)] pub fn from_text(text: &str) -> SharedPtr { set_panic_hook(); let view: Vec<u8> = text.as_bytes().to_vec(); SharedPtr::new(view) } #[wasm_bindgen(catch)] pub fn encode(&self, encode: Encode) -> String { set_panic_hook(); let view: Vec<u8> = utils::raw_from_sharedptr(self); match encode { Encode::BASE64 => utils::base64_encode(view), Encode::HEX => utils::hex_encode(view), } } #[wasm_bindgen(catch)] pub fn binary_to_str(&self) -> Result<String, JsValue> { set_panic_hook(); let view: Vec<u8> = utils::raw_from_sharedptr(self); match String::from_utf8(view) { Ok(res) => Ok(res), Err(_) => Err(JsValue::NULL), } } }
I expected to see this happen: explanation
Instead, this happened: explanation
rustc --version --verbose:
rustc --version --verbose
rustc 1.48.0-nightly (f3c923a13 2020-09-17) binary: rustc commit-hash: f3c923a13a458c35ee26b3513533fce8a15c9c05 commit-date: 2020-09-17 host: x86_64-apple-darwin release: 1.48.0-nightly LLVM version: 11.0
error: linking with `rust-lld` failed: signal: 6 | = note: "rust-lld" "-flavor" "wasm" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--fatal-warnings" "--no-demangle" "--export-dynamic" "--no-entry" "-L" "/user path/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib" "-L" "/user path/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/self-contained" "/user path/Workspace/TSWASM/built/rust/target/wasm32-unknown-unknown/release/deps/wasm_security.wasm_security.2iyg1b5p-cgu.15.rcgu.o" "-o" "/user path/Workspace/TSWASM/built/rust/target/wasm32-unknown-unknown/release/deps/wasm_security.wasm" "--export" "__wbg_cbc_free" "--export" "__wbg_ecb_free" "--export" "__wbg_get_sharedptr_at_ptr" "--export" "__wbg_get_sharedptr_cap" "--export" "__wbg_get_sharedptr_len" "--export" "__wbg_rsaprivate_free" "--export" "__wbg_rsapublic_free" "--export" "__wbg_set_sharedptr_at_ptr" "--export" "__wbg_set_sharedptr_cap" "--export" "__wbg_set_sharedptr_len" "--export" "__wbg_sharedptr_free" "--export" "__wbindgen_describe___wbg_get_sharedptr_at_ptr" "--export" "__wbindgen_describe___wbg_get_sharedptr_cap" "--export" "__wbindgen_describe___wbg_get_sharedptr_len" "--export" "__wbindgen_describe___wbg_log_2cc37b6086724e15" "--export" "__wbindgen_describe_cbc_decrypt" "--export" "__wbindgen_describe_cbc_encrypt" "--export" "__wbindgen_describe_cbc_from" "--export" "__wbindgen_describe_ecb_decrypt" "--export" "__wbindgen_describe_ecb_encrypt" "--export" "__wbindgen_describe_ecb_from" "--export" "__wbindgen_describe_rsaprivate_decrypt" "--export" "__wbindgen_describe_rsaprivate_encrypt" "--export" "__wbindgen_describe_rsaprivate_from_pkcs1" "--export" "__wbindgen_describe_rsaprivate_from_pkcs8" "--export" "__wbindgen_describe_rsaprivate_pub_encrypt" "--export" "__wbindgen_describe_rsapublic_encrypt" "--export" "__wbindgen_describe_rsapublic_from_pkcs1" "--export" "__wbindgen_describe_rsapublic_from_pkcs8" "--export" "__wbindgen_describe_shared_memory" "--export" "__wbindgen_describe_sharedptr_binary_to_str" "--export" "__wbindgen_describe_sharedptr_encode" "--export" "__wbindgen_describe_sharedptr_from_text" "--export" "__wbindgen_describe_sharedptr_with_capacity" "--export" "cbc_decrypt" "--export" "cbc_encrypt" "--export" "cbc_from" "--export" "ecb_decrypt" "--export" "ecb_encrypt" "--export" "ecb_from" "--export" "rsaprivate_decrypt" "--export" "rsaprivate_encrypt" "--export" "rsaprivate_from_pkcs1" "--export" "rsaprivate_from_pkcs8" "--export" "rsaprivate_pub_encrypt" "--export" "rsapublic_encrypt" "--export" "rsapublic_from_pkcs1" "--export" "rsapublic_from_pkcs8" "--export" "shared_memory" "--export" "sharedptr_binary_to_str" "--export" "sharedptr_encode" "--export" "sharedptr_from_text" "--export" "sharedptr_with_capacity" "--export" "__externref_drop_slice" "--export" "__externref_heap_live_count" "--export" "__externref_table_alloc" "--export" "__externref_table_dealloc" "--export" "__wbindgen_exn_store" "--export" "__wbindgen_free" "--export" "__wbindgen_malloc" "--export" "__wbindgen_realloc" "--export" "__wbindgen_describe___wbg_error_4bb6c2a97407129a" "--export" "__wbindgen_describe___wbg_new_59cb74e423758ede" "--export" "__wbindgen_describe___wbg_stack_558ba5917b466edd" "--export=__heap_base" "--export=__data_end" "--gc-sections" "--no-entry" "-O2" "-L" "/user path/Workspace/TSWASM/built/rust/target/wasm32-unknown-unknown/release/deps" "-L" "/user path/Workspace/TSWASM/built/rust/target/release/deps" "-L" "/user path/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib" "/user path/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/wasm32-unknown-unknown/lib/libcompiler_builtins-e1980b88fd1d13d6.rlib" = note: dyld: Library not loaded: @rpath/libLLVM.dylib Referenced from: /user path/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/bin/rust-lld Reason: image not found
The text was updated successfully, but these errors were encountered:
Duplicate of #76698, being fixed in #76810.
Sorry, something went wrong.
No branches or pull requests
I tried this code:
I expected to see this happen: explanation
Instead, this happened: explanation
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: