Emscripten-wasm: Add options to enable SIMD and Threads - #12
Conversation
Signed-off-by: Squareys <squareys@googlemail.com>
|
Eh, not sure about this at all. The main problem is that the toolchain file gets read only once, so in case you'd ever want to enable/disable these features later, changing the flag will not do anything (and you won't know it did nothing) unless you recreate the build dir. Second, this is something that I think should not get enabled on a global level. Even now in Magnum I have a bunch of tests and utility executables where I want to have different flags on each to test different functionality. And if a certain app (let's say a computationally-heavy example) needs to enable threads and/or SIMD, it shouldn't get enabled for all others, making all others suddenly not run on browsers w/o threads/SIMD. The way threads are currently done in CMake is in the For the SIMD stuff, I'm not sure. I'm still investigating general SIMD optimizations in magnum, so I don't know which way is the right way and whether e.g. a wasm module with SIMD ops can run on non-SIMD-enabled browsers if you never hit the SIMD code path, or if you need a totally separate binary. I'd say you just add these flags in your global |
|
@mosra Thing with Threads is that it needs to be enabled in every compiled object, not just in the final application. To use threads, I need to recompile every single dependency of my application, so on a global level is mandatory here. For SIMD I'm not sure, especially since that only requires a compile-time flag, that could be enabled per compiled object. I think there is a argument in "WASM-SIMD" or "WASM-Threads" being their own platforms and therefor this is just a nicer way of saying |
|
I honestly don't think neither suggested option is the right direction. This doesn't belong to a toolchain file, it's just two non-mandatory compiler flags.
Seriously, what's wrong with modifying |
|
@mosra I did not seriously propose the second option, it overlaps very much with Emscripten-wasm.cmake so as you said that would just be hard to maintain. It's not just a compiler flag, What I'm saying that libraries/objects that have vs do not have this flag cannot be linked together. I guess I can go for |
According to my experience, CMake passes compiler flags to the linker as well ;) Maybe it's platform-dependent, so check to be really sure.
The presence of the flag in the toolchain file doesn't make that any easier tho. If you accidentally build a dependency without the toolchain option enabled, it's the same as if you'd forget the flag. Closing this -- simply use |
True 👍 I solved this now by setting |
Hi @mosra !
As these feature are getting ready/are ready in modern browsers, here's a proposal how they could be supported in the toolchain.
Best,
Jonathan