Compiling either to Linux or WASM concerns
wwderw opened this issue · 16 comments
First off, glad that I found this project, compiling JS is what I have been looking for and not having to deal with obfuscation.
I seem to be struggling with compiling. Using GCC that came with Ubuntu Studio 20.10, which is 10.2 if I recall.
I can successfully use the hello world from sandboxed demo. I noticed that it spits out a *.bin file.
When compiling the exact program in my js file usingnectar [fileName].js
it compiles without an extension, let alone .bin and when running in Konsole, I get Segmentation Fault(core dumped)
Any help in that regard would be appreciated.
As far as the WASM goes, I'm coming from emscripten and it would also spit out a glue js file for the wasm. Are we supposed to get that as well or is that manually needed to be done?
Thanks and looking forward to using this compiler.
Hi @wwderw ,
Thank you for your interest in NectarJS,
Regarding the segfault problem, which version NectarJS are you using ?
For the wasm env, you can generate the js glue file with the flag -- target js
Nectar version is 0.7.110.
Can you try with v0.7.109 ?
Npm says package doesn't exist.
sorry, v0.7.108
I found the problem in v0.7.110, I corrected it in b7fdac8
I will publish the updated version v0.7.111 on npm
I was able to get the binary to run on the older version.
WASM ran on the latest, but couldn't get it to run on the older version. Wanted external, but couldn't find the same version, and it had errored on the 109 version. Which was the one I found on npm's site.
I must say though the WASM is my first use case as I mainly deal with SPAs.
Looking to trying it out on one over the holiday weekend.
Thanks for the help. Anything else I might be able to test, let me know.
Just now saw your slightly earlier reply from my latest I'll be on the lookout for the latest version and give both outputs a shot and let you know.
Thanks again.
I just published the v0.7.111, give me your feedback when you can test
By the time that I got it, it was already at 0.7.112.
I ran 2 tests as far as JS functions exporting to both targets (linux and wasm). The tests with console.log compiled and ran fine under both. When I added an alert function, that's when it threw an error (uncaught in promise: 5313368).
I'll be working on a more "complicated" project here over the holiday, so that should give me a better idea.
So just for quick testing, I decided to take an audio player that I had created and convert it to WASM.
The error that it threw was: Uncaught (in promise) 5314296. Which led to column 102275 in the glue js file. Outside of that, I don't know where else to look for more info.
all the DOM environment is not binded to wasm yet, that's why you have this errors
could you share an example of code that you would like to compile ?
That makes sense and considering emscripten doesn't have direct manipulation of the DOM that would further that assessment.
I also added event listeners to svg elements as I used a custom player that I created as an svg, so attached to those elements may also caused it to get hinky.
You can communicate between dom and wasm with json for now
Btw, with the html5.h lib from emscripten, it could be possible to access the dom directly