Skip to content
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

How does emscripten generate 32-bit and 64-bit wasm #19833

Closed
yangfangfang1204 opened this issue Jul 11, 2023 · 19 comments
Closed

How does emscripten generate 32-bit and 64-bit wasm #19833

yangfangfang1204 opened this issue Jul 11, 2023 · 19 comments

Comments

@yangfangfang1204
Copy link

Does wasm distinguish between 32-bit and 64-bit, and why does it appear Target: wasm32-unknown-emscripten after emcc-v .

How does emscripten generate 32-bit and 64-bit wasm ?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 11, 2023

We use the -sMEMORY64 setting.

@yangfangfang1204
Copy link
Author

and i add -sMEMORY64 , there is a warning: -sMEMORY64 is still experimental. Many features may not work. so what features can't be used ?

And i run the hello.html in chromeV114-64bit , chrome return the error: invalid memory limits flags 0x5(enable via --experimental-wasm-memory64) ? so memory64 is still experimental , if i want to use it , What do I need to pay attention to ?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

The places where support is limited is in the JS library code and in the interaction with JS.

Some major features that I know don't work yet are -sASYNCIFY and webgl bindings.

@yangfangfang1204
Copy link
Author

if i decode a video by ffmpeg and render the yuv by opengl , then emcc the ffmpeg-decode module and opengl render module to the ffmpeg.wasm.

the ffmpeg.wasm not support wasm64 ?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

I imagine it will easy to compile ffmpeg.wasm for memory64. The rendering part might not work correctly though.. there are some open PRs related to webGL support.

@yangfangfang1204
Copy link
Author

OK, where is the open PRs related to webGL support in wasm64 ?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

#18744
#19289

@yangfangfang1204
Copy link
Author

thanks. and i run the helloword.html (-s MEMORY64 ) , the chrome return the error invalid memory limits flags 0x5 (enable via --experimental-wasm-memory64) @+365) , this need some setting ?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

You can use --enable-experimental-webassembly-features and --js-flags=--experimental-wasm-memory64

@yangfangfang1204
Copy link
Author

that means chrome doesn't support memory64 now , we need set experimental flags to enable it ?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

Yes, its not yet standardized and still experimental, both in the toolchain and the browsers.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

What is more, until this change land you won't even be able to actually allocate a memory larger than 4gb: #19737

@yangfangfang1204
Copy link
Author

When will it be standardized and released, and how long will it take, one year? two year? We can plan our work according to stadardized time.

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

My hope is that it will reach stage 4 (This basically means it is standardized and will be available in chrome and other browsers without a flag) this year. However, there is obviously no guarantee.

@yangfangfang1204
Copy link
Author

ok , thanks . i test a decode time , it need 20ms to decode one frame by ffmpeg.wasm32 , and it need 30ms to decode the same frame by ffmpeg.wasm64 . Why does wasm64 take longer to decode than wasm32?

@sbc100
Copy link
Collaborator

sbc100 commented Jul 12, 2023

Thats pretty hard to say. One possible cause of slowdown is the larger pointer size.. this can effect the data locality since it can increase the sizes of structs (and things like vtables).

@sbc100
Copy link
Collaborator

sbc100 commented Jul 31, 2023

I think the original question has been answered here: -sMEMORY64.

@sbc100 sbc100 closed this as completed Jul 31, 2023
@tra4less
Copy link

tra4less commented Nov 8, 2023

ok , thanks . i test a decode time , it need 20ms to decode one frame by ffmpeg.wasm32 , and it need 30ms to decode the same frame by ffmpeg.wasm64 . Why does wasm64 take longer to decode than wasm32?

May I ask how to compile wasm64? I always get the error: wasm-ld: error: ffmpeg/src/ffmpeg_project-build/libavutil/libavutil.a(mathematics.o): wasm32 object file can't be linked in wasm64 mode.

@sbc100
Copy link
Collaborator

sbc100 commented Nov 8, 2023

You need to recompile ffmpeg/src/ffmpeg_project-build/libavutil/libavutil.a (and all the object files within in) with -sMEMORY64

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