bytecodealliance / cargo-wasi

A lightweight Cargo subcommand to build Rust code for the `wasm32-wasi` target
https://bytecodealliance.github.io/cargo-wasi/
Apache License 2.0
444 stars 29 forks source link

fix: wasm_opt #114

Open ChenKS12138 opened 2 years ago

ChenKS12138 commented 2 years ago
  1. As @PiotrSikora says, in order to runwasm_opt, a dynamic library needs to be installed (for Linux and mac os). https://github.com/bytecodealliance/cargo-wasi/pull/91#issuecomment-787433832 And the cache folder's structure will be as follow.

image

  1. update wasm_opt version from version_97 to version_105
ChenKS12138 commented 2 years ago

Oops, some checks are stills be not successful, IMHO maybe examples/markdown is not a suitable example for cargo-wasi, we need to remove it, as @alexcrichton says

the wasm32-wasi target is not compatible with wasm-bindgen

https://github.com/rustwasm/wasm-bindgen/issues/2554#issuecomment-840774170

Or, we should allow users to pass and override the target argument, something like that. (It works well to compile examples/markdown if I have changed the target)

cargo wasi build -p markdown --release --verbose --target wasm32-unknown-unknown

https://github.com/bytecodealliance/cargo-wasi/blob/6d2e50238275e1cd4cc2e6c4755f1d3d26d2742b/src/lib.rs#L82-L94

ChenKS12138 commented 2 years ago
  1. As @PiotrSikora says, in order to runwasm_opt, a dynamic library needs to be installed (for Linux and mac os). Update wasm-opt to version_97. #91 (comment) And the cache folder's structure will be as follow.

image

  1. bump wasm_opt version from version_97 to version_105
  1. Installing target wasm32-unknown-unknown when compiling example/markdown on CI.
alexcrichton commented 2 years ago

Sorry there's a good number of changes here and I don't have a ton of time to review this right now. If wasm-opt-the-builtin-version isn't working well I'd recommend disabling it and then manually running it afterwards.

ChenKS12138 commented 2 years ago

I have removed the code that updating wasm-opt version, and I believe this is the minimum code changes to let CI checks pass.

There is no problem with wasm-opt-the-builtin-version, but an essential library (libbinaryen.dylib/libbinaryen.a) is not installed and linked.