You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by ansemjo October 22, 2024
Hey there,
I recently attempted to compile OMNeT++ simulations to WebAssembly (specifically the WASI "preview1" / wasip1 target) by using the wasi-sdk as a toolchain. In a first step, I tested how to compile OMNeT++ to static libraries, that don't depend on any system libraries at runtime; and that worked fine. However, since each simulation project is basically an executable that links against the OMNeT++ library, the library itself needs to be compiled to a WebAssembly format, that the wasi-sdk toolchain can then link against. And now that's where I am stuck.
Is there any interest to support WebAssembly as a compilation target in the future?
There is already zigen/omnetpp-wasm but that focuses on using Emscripten to package the entire Qt GUI on a webpage. It's amazing that this works but I'd be more interested in the standalone mode to produce WASI binaries of only the Cmdenv. Maybe I'll just need to look into this again to see if it can be repurposed.
It's been a while since I've tested this so here are some (probably incomplete) notes:
To build OMNeT++ with static libraries, set in configure.user:
Attempt to build the simulation with the wasi-sdk:
opp_makemake -f --deep -u Cmdenv -L $__omnetpp_root_dir/lib \
-K CFLAGS=-static -K LDFLAGS=-static \
# use emulated signals in wasi-sdk:
-lwasi-emulated-signal -D_WASI_EMULATED_SIGNAL \
# do not use POSIX coroutines in omnetpp:
-DUSE_PORTABLE_COROUTINES
But that fails because the previously compiled static library cannot be linked with WebAssembly modules.
So rebuild OMNeT++ itself with the wasi-sdk. Setting CXX and CC beforehand didn't work, so I added the SDK to PATH and masked those explicitly for configure:
But now running make fails due to various longjmp errors that appear to arise due to the use of exceptions. My current understanding is that you could enable experimental support for exceptions in WebAssembly but neither wasmtime nor a browser envionment currently supports that anyway. I've also seen that SQLite is linked a few times and while SQLite now has a dedicated Wasm build, doing the same for an older version that is bundled with the project is probably quite hard.
The text was updated successfully, but these errors were encountered:
Discussed in #1241
Originally posted by ansemjo October 22, 2024
Hey there,
I recently attempted to compile OMNeT++ simulations to WebAssembly (specifically the WASI "preview1" /
wasip1
target) by using the wasi-sdk as a toolchain. In a first step, I tested how to compile OMNeT++ to static libraries, that don't depend on any system libraries at runtime; and that worked fine. However, since each simulation project is basically an executable that links against the OMNeT++ library, the library itself needs to be compiled to a WebAssembly format, that the wasi-sdk toolchain can then link against. And now that's where I am stuck.Is there any interest to support WebAssembly as a compilation target in the future?
There is already zigen/omnetpp-wasm but that focuses on using Emscripten to package the entire Qt GUI on a webpage. It's amazing that this works but I'd be more interested in the standalone mode to produce WASI binaries of only the Cmdenv. Maybe I'll just need to look into this again to see if it can be repurposed.
It's been a while since I've tested this so here are some (probably incomplete) notes:
configure.user
:Then run
make clean && make -j$(nproc)
as usual.But that fails because the previously compiled static library cannot be linked with WebAssembly modules.
CXX
andCC
beforehand didn't work, so I added the SDK toPATH
and masked those explicitly for configure:A small dummy enum is needed in
src/common/filelock.h
(reference):But now running
make
fails due to variouslongjmp
errors that appear to arise due to the use of exceptions. My current understanding is that you could enable experimental support for exceptions in WebAssembly but neitherwasmtime
nor a browser envionment currently supports that anyway. I've also seen that SQLite is linked a few times and while SQLite now has a dedicated Wasm build, doing the same for an older version that is bundled with the project is probably quite hard.The text was updated successfully, but these errors were encountered: