old-storyai / tracing-wasm

`tracing` crate compatible `Subscriber` for reporting spans through browser `window.performance`
Apache License 2.0
69 stars 22 forks source link

Unable to build for wasm32-unknown-emscripten #24

Open DSchroer opened 1 year ago

DSchroer commented 1 year ago

From a empty project and adding tracing-wasm as a dependency. Building with cargo build --target wasm32-unknown-emscripten fails due to the following error:

= note: error: undefined symbol: main/__main_argc_argv (referenced by top-level compiled C/C++ code)
          warning: Link with `-sLLD_REPORT_UNDEFINED` to get more information on undefined symbols
          warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
          warning: _main may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
          warning: To build in STANDALONE_WASM mode without a main(), use emcc --no-entry
          Error: Aborting compilation due to previous errors
          emcc: error: '/usr/bin/node /usr/lib/emscripten/src/compiler.js /tmp/tmpxlhf40bq.json' failed (returned 1)
colelawrence commented 1 year ago

I'm open to others taking a look. I haven't used this build triple and I don't recognize the error.

happydpc commented 1 year ago

There should set EMCC_CFLAGS flag value with -no-entry.

EMCC_CFLAGS="-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry -s FULL_ES3=1"

//https://github.com/gfx-rs/wgpu/wiki/Running-on-the-web-with-Emscripten