iroha icon indicating copy to clipboard operation
iroha copied to clipboard

`iroha_wasm_builder`: remove `cargo` invocation

Open Arjentix opened this issue 2 years ago • 7 comments

Right now there is a problem -- we have to invoke cargo from our iroha_wasm_builder to be able to build Rust Smartcontract in WASM. That can cause problems with cargo recursion problem (cargo doesn't like to be invoked multiple times from it self).

There is a wasm-builder crate which can help us with that. But I'm not 100% sure it can do all what we need. We need to do a research and try to use it

Arjentix avatar Apr 26 '22 17:04 Arjentix

Maybe we can use cargo as library.

Erigara avatar Feb 02 '23 10:02 Erigara

@Erigara , cool idea

Arjentix avatar Mar 24 '23 15:03 Arjentix

Blocked by https://github.com/hyperledger/ursa/issues/232

Arjentix avatar Apr 17 '23 14:04 Arjentix

That can cause problems with cargo recursion problem (cargo doesn't like to be invoked multiple times from it self).

@Arjentix, What are some of the problems that can be encountered? I only seem to find https://github.com/rust-lang/cargo/issues/6412, and this one:

  1. is already worked around by setting CARGO_TARGET_DIR to OUT_DIR in wasm_builder
  2. wouldn't be solved by using cargo as a library, as the build dir lock is still there

DCNick3 avatar Oct 16 '23 07:10 DCNick3

@DCNick3 , the problem was found when we were using our cargo lints. Because of that in iroha_wasm_builder we unset CARGO_RECURSION env var. Probably now there's no problem, need to test it.

Arjentix avatar Oct 16 '23 09:10 Arjentix

I think it's actually called RUST_RECURSION_COUNT..

DCNick3 avatar Oct 17 '23 08:10 DCNick3

I don't think that using cargo as a library is a good idea.

Mainly because its API is perma-unstable and is not gonna be stabilized soon.

Other problem I can see is ignoring the rustup config, but ig with us using a pinned nightly version for building smart contracts that's wouldn't be a problem.

And, well, it doesn't seem necessary IMO: the RUST_RECURSION_COUNT workaround is not necessary w/o cargo lints (I wasn't getting any problems when disabling it).

There's also CARGO_ENCODED_RUSTFLAGS workaround: (https://github.com/hyperledger/iroha/blob/f9f5ede6791a99ec788a05755867e1fcb497a9e2/wasm_builder/src/lib.rs#L402C1-L406C47). This one still seems to still be required, but I think it's better then chasing a perma-unstable API.

DCNick3 avatar Oct 18 '23 07:10 DCNick3