emscripten-core / emsdk

Emscripten SDK
http://emscripten.org
Other
2.92k stars 662 forks source link

compile wams64 using bazel mode #1362

Closed phoenix20162016 closed 3 months ago

phoenix20162016 commented 3 months ago

in default bazel config, the build env is under 32bit mode, how can i switch to 64bit mode

sbc100 commented 3 months ago

To build for wasm64 you can add -sMEMORY64 to you compile and link commands.

phoenix20162016 commented 3 months ago

image @sbc100 follows your suggestion,another error occurs, the following is my bazel configuration image

in the fold of the compiler tools, the wasm64-emscripten dir really does not exist

sbc100 commented 3 months ago

I see, yes we don't currently wasm64 versions of any core libraries in the bazel toolchain. I think this is the same as https://github.com/emscripten-core/emsdk/issues/807. Perhaps we can close this and continue the discussion there?

wzheng21 commented 2 months ago

@phoenix20162016 I had the same problem as yours. For whoever having similar issues, I had to patch emsdk setting FROZEN_CACHE = False in config.py, then the issue becomes read-only blabla error, basically indicating emscripten tries to compile libraries and writes into a temporary cache folder but failed.

This of course would fail, due to bazel's idea of keeping builds hermitian. The following are the two different workarounds I tested that worked:

  1. Disable bazel sandbox mode. Just specify --spawn_strategy=local. Be careful when using this, especially if this is not a toy project
  2. Don't play with sandbox, but specify --action_env=EM_CACHE=~/.cache/emscripten_cache. When FROZEN_CACHE is False, emscripten will try to write to ~/.emscripten_cache, which will definitely fail in bazel sandbox mode due to permissions. Writing to ~/.cache folder, however, is allowed.

Hope this is helpful for anyone getting stuck with this issue.