-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
compile API to WASM #1073
Comments
I think it should work like this, but it doesn't:
|
starting with a clean clone and emscripten installation, I commented out
|
As I said: #892 (comment) |
I finally managed running LibreDWG in the browser. FYI anyone needing this: The error above was probably caused by a wrong CC environment variable or installation or something.
I wrote a separate JSON conversion program using dwg_decode/dwg_decode directly (as well as dwg_fixup_BLOCKS_entities for DWG downgrades), since dependency on filenames as per the original API is unnecessary and undesirable in my opinion, although emscripten does provide a limited virtual fs. It's possible to call those functions directly from JS, without create a separate library/program. I used Node.js and emscripten from the emsdk repository and installed a bunch of other stuff, but I'm not sure what's necessary. The source map doesn't work but I can see file names and line numbers when WASM crashes. I probably won't have time for a long time to create an automatic WASM build, javascript bindings or NPM library. I need to figure out how to set SIDE_MODULE=2/MAIN_MODULE=2 to avoid all functions being exposed, but the LibreDWG API is in there and could be used (I prefer working with JSON however). Currently there is a bug in Chrome 133 for debug symbols, so you need to use 134 beta or another browser. You probably also need the DWARF browser extension. It seems there is a bug in emscripten occurring within calloc within hash_new (hash.c); it's unclear what could be causing this but the source code (dlmalloc function) is available here: https://github.com/emscripten-core/emscripten/blob/main/system/lib/dlmalloc.c. -O2 or -O3 also seems necessary to avoid an error of too many local variables; there might be a big buffer in the stack somewhere. |
This compiles the library (libredwg.a) but a.wasm is 1kb.
How do I get a libredwg.wasm that contains the actual exports?
Related to #876
The text was updated successfully, but these errors were encountered: