Skip to content

Building and Running WASM in -sMEMORY64=1 mode #14582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
donalffons opened this issue Jul 2, 2021 · 7 comments
Closed

Building and Running WASM in -sMEMORY64=1 mode #14582

donalffons opened this issue Jul 2, 2021 · 7 comments

Comments

@donalffons
Copy link

Hi,

I noticed that Emscripten has the option to run in "full end-to-end wasm64 mode" with the build flag -sMEMORY64=1. I would be interested in trying that, since my use case (loading and converting large 3D models) can easily break the 4GB memory limit of WASM32.

My question is: Is it possible to use the -sMEMORY64=1 builds today? I think the optimal scenario for my use case would be to run a NodeJS / Deno + V8 with WASM64 support on a server. Is that possible? Or is there an alternative approach to this?

Any hints would be much appreciated!

@sbc100
Copy link
Collaborator

sbc100 commented Jul 2, 2021

This is probably a question better asked over at https://github.com/WebAssembly/memory64.

According to https://github.com/WebAssembly/proposals, memory64 is currently in phase 3, so folks are implementing it now. It would probably be unwise to start using in production until it reaches phase 4.

In terms of where we are in emscripten itself with memory64 support, IIRC there is at least one major PRs still to land #12869.

@aardappel will know more about where we are on v8 and other places.

@donalffons
Copy link
Author

I didn't know about the different phases for the various proposals. Thanks for pointing that out! Definitely good to see that WASM64 is already in phase 3.

If there is a way (and if it makes sense) to "beta test" this today or some time in the future - I would be interested 🙂.

I will also ask over at the WebAssembly/memory64 repository, as you suggested.

Thanks for your help!

@donalffons
Copy link
Author

Hmm, so I made a quick experiment and added -sMEMORY64=1 (and in a second test -sMEMORY64=2 with identical outcome) to the build options for my project's code (this one). The project is using Embind.

The compilation steps (compiling .cpp into .o files) run fine, but I get the following error in the final build/linking phase (taking only .o files as inputs to generate .wasm):

In file included from /opencascade.js/build/bindings/Standard/Standard_Dump.hxx/Standard_DumpValue.cpp:7609:
In file included from /emsdk/upstream/emscripten/cache/sysroot/include/emscripten/bind.h:21:
/emsdk/upstream/emscripten/cache/sysroot/include/emscripten/val.h:197:9: error: static_assert failed due to requirement 'sizeof(emscripten::internal::GenericWireType) == 8' "GenericWireType must be 8 bytes"
        static_assert(sizeof(GenericWireType) == 8, "GenericWireType must be 8 bytes");
        ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Simply commenting out those two assertions in val.h, leads to more failed assertions here. Commenting those leads to a type mismatch here. Fixing that manually leads to error: no member named '__pad1' in 'struct msghdr' here.

So, yeah, it's probably a bit early to try this just yet... Looking forward to this important feature, though!

@donalffons donalffons changed the title Running WASM in -sMEMORY64=1 mode Building and Running WASM in -sMEMORY64=1 mode Jul 3, 2021
@aardappel
Copy link
Collaborator

@donalffons there's no point trying it now, as there is not just one bit of code broken under Memory64, but hundreds. The PR @sbc100 linked should give you an idea of the kind of things that need fixing, and it's only very partially complete.

@donalffons
Copy link
Author

Alright, I see... Thanks for you answer.
Do you have an idea on how long it will take until this is supported in Emscripten (and V8), at this point? I'm curious if this is going to take one year? Or two? Or five?

@aardappel
Copy link
Collaborator

This one answers that best: WebAssembly/memory64#20

I would certainly hope less than 1 year but you never know with these things.

@donalffons
Copy link
Author

Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants