proxy-wasm-rust-sdk icon indicating copy to clipboard operation
proxy-wasm-rust-sdk copied to clipboard

Question around cargo wasi start and testing

Open derwolfe opened this issue 2 years ago • 0 comments

The issue

Hi! I've been using the rust SDK and it's been working quite well for me thus far. I've been interested in pulling in some of web_sys from wasm_bindgen and also wanted to have my tests run in a wasi environment. I followed the directions at https://bytecodealliance.github.io/cargo-wasi/testing.html to try to get my environment bootstrapped, but on attempting to run cargo wasi test the following error was returned.

  = note: rust-lld: error: duplicate symbol: _start
          >>> defined in /Users/cwolfe/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/self-contained/crt1-command.o
          >>> defined in /Users/cwolfe/Code/proxy-wasm-e2etoken-filter/target/wasm32-wasi/debug/deps/proxy_wasm_e2etoken_filter-91c1493ef37ea735.49s9in10l20plzkv.rcgu.o

switching to proxy_wasm::main!, a different error is returned

    0: failed to instantiate "/Users/cwolfe/Code/proxy-wasm-e2etoken-filter/target/wasm32-wasi/debug/deps/proxy_wasm_e2etoken_filter-91c1493ef37ea735.wasm"
    1: Program cannot be both a Command and a Reactor

Why am I asking this here?

There look to be two ways to structure the filter, either by defining a _start entrypoint or using the main! macro that builds the same. It seems like you might have guidance around how I might be able to structure my code get around this.

Thanks!

derwolfe avatar Apr 05 '23 16:04 derwolfe