aurora-rs / stellar-base-rs

Low level Stellar types for Rust.
https://docs.rs/stellar-base
Apache License 2.0
8 stars 6 forks source link

Issue compiling for wasm32 #3

Closed mcaruso85 closed 3 years ago

mcaruso85 commented 3 years ago

Hi,

When I run:

'cargo build --target wasm32-unknown-unknown --package rust_hello --release'

I get:

Executing 'cargo build --target wasm32-unknown-unknown --package rust_hello --release' Compiling libsodium-sys v0.2.6 Compiling syn v0.15.44 error: failed to run custom build command for libsodium-sys v0.2.6

Caused by: process didn't exit successfully: /Users/anyuser/Development/rust_hello/target/release/build/libsodium-sys-dff060a91738b3fa/build-script-build (exit code: 101) --- stdout cargo:rerun-if-env-changed=SODIUM_LIB_DIR cargo:rerun-if-env-changed=SODIUM_SHARED cargo:rerun-if-env-changed=SODIUM_USE_PKG_CONFIG cargo:rerun-if-env-changed=SODIUM_DISABLE_PIE OPT_LEVEL = Some("3") TARGET = Some("wasm32-unknown-unknown") HOST = Some("x86_64-apple-darwin") CC_wasm32-unknown-unknown = None CC_wasm32_unknown_unknown = None TARGET_CC = None CC = None CFLAGS_wasm32-unknown-unknown = None CFLAGS_wasm32_unknown_unknown = None TARGET_CFLAGS = None CFLAGS = None CRATE_CC_NO_DEFAULTS = None DEBUG = Some("false") checking build system type... x86_64-apple-darwin20.3.0 checking host system type... --- stderr Invalid configuration wasm32-unknown-unknown': OSunknown' not recognized configure: error: /bin/sh build-aux/config.sub wasm32-unknown-unknown failed

Does this support build for wasm32 ?

Thanks

fracek commented 3 years ago

Hi, unfortunately it's not compatible with wasm because of the dependency on libsodium. AFAIK there is no libsodium-like implementation for wasm. How do you plan to use the library? Maybe we can conditionally remove the key-related features when compiling for wasm.

mcaruso85 commented 3 years ago

Hi, unfortunately it's not compatible with wasm because of the dependency on libsodium. AFAIK there is no libsodium-like implementation for wasm. How do you plan to use the library? Maybe we can conditionally remove the key-related features when compiling for wasm.

Hi Fracek,

Thanks for your quick reply. I would like to use this library in a canister for Internet Computer, which requires to compile to wasm. And I would like to be able to sign transactions, so I will need the key features. I was trying to find out if there are crates for signing that can compile for wasm, I'm basically new to rust. Will something like this ed25519-dalek = "1.0.1" work? But I understand this will require a change in the code impl.

fracek commented 3 years ago

Yes I think that I may work. We need to check that all dependencies work on wasm (I don't know how to check for that to be honest). Maybe remove all code depending on libsodium + signing and see what happens? If it compiles then I'm open to change the crypto library we use.

mcaruso85 commented 3 years ago

Hi, I can compile to wasm using:

cargo build --target wasm32-unknown-unknown --package rust_hello --release

But I think I will have to fork and see if I can make it work with that library. It will take me sometime.

We can close this issue.

Thanks !